Background
⌘K

WordPress Integration

Learn how to integrate Affonso affiliate tracking into your WordPress website.

Silvestro
Written by Silvestro
Updated more than a month ago

WordPress offers multiple ways to add tracking scripts, from theme customization to plugins, making it flexible for different user comfort levels and site setups.

Add tracking script to your WordPress site

The recommended approach is to use a plugin for safe, code-free installation that survives theme updates and doesn't require technical knowledge.

  1. Install the Insert Headers and Footers plugin

  2. Go to Settings → Insert Headers and Footers

  3. In the Scripts in Header section, add your tracking script:

    <script
      async
      defer
      src="https://affonso.io/js/pixel.min.js"
      data-affonso="YOUR_PUBLIC_PROGRAM_ID"
      data-cookie_duration="YOUR_COOKIE_DURATION"
    ></script>

Find your Program ID →

Alternative: Add the script via your theme's functions.php file using the wp_head action hook, or directly in your theme's header.php file. See WordPress's official guide on adding code to header for more advanced options.

Testing

  1. Visit your WordPress site with ?atp=test
  2. Check browser DevTools → Console → type window.affonso_referral
  3. Verify the script appears in your page source
  4. Deploy and verify tracking in your Affonso dashboard

Note: If using caching plugins, clear your cache after installation.

Multi-Domain Setup

If you're using WordPress only for your marketing site (e.g., yourcompany.com) and your application runs on a subdomain (e.g., app.yourcompany.com), make sure to install the Affonso tracking script on both domains.

Affonso works seamlessly across subdomains - the same affiliate cookie will be shared between yourcompany.com and app.yourcompany.com. See our multi-domain setup guide for more details on cross-domain tracking.

Next Steps

Once installed, you can access affiliate referral data and pass it to your payment provider. Connect your payment provider →

Was this article helpful?

If you still need help, our support team is here for you.

Contact Support
bg

Ready to Scale Your SaaS?

Affonso is the easiest way to launch your own affiliate program. We take care of the technical stuff, so you can focus on growing your business.