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.
-
Install the Insert Headers and Footers plugin
-
Go to Settings → Insert Headers and Footers
-
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>
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
- Visit your WordPress site with
?atp=test
- Check browser DevTools → Console → type
window.affonso_referral
- Verify the script appears in your page source
- 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 →