Background
⌘K

Drupal Integration

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

Silvestro
Written by Silvestro
Updated more than a month ago

Drupal's flexible theme system and custom code capabilities make it easy to add tracking scripts globally across your entire website, ideal for enterprise organizations using Drupal for their web presence.

Add tracking script to your Drupal site

The recommended approach is to add the script to your active theme's template files, ensuring the script loads on all pages consistently.

  1. Access your Drupal site files via FTP or file manager
  2. Navigate to your active theme folder (usually /themes/custom/your-theme/ or /themes/your-theme/)
  3. Open your main template file (typically page.html.twig or html.html.twig)
  4. Add the tracking script in the <head> section:
<head>
  {{ head }}

  <script
    async
    defer
    src="https://affonso.io/js/pixel.min.js"
    data-affonso="YOUR_PUBLIC_PROGRAM_ID"
    data-cookie_duration="YOUR_COOKIE_DURATION"
  ></script>
</head>
  1. Clear Drupal's cache (Admin → Configuration → Performance → Clear all caches)

Find your Program ID →

Alternative: Use a custom module or the "Insert Flickers" module to add the script without modifying theme files.

For more details, see Drupal's theming documentation and template file guide.

Testing

  1. Clear your Drupal cache after adding the script
  2. Visit your Drupal site with ?atp=test
  3. Check browser DevTools → Console → type window.affonso_referral
  4. Verify tracking in your Affonso dashboard

Note: Changes to template files require cache clearing to take effect.

Multi-Domain Setup

If you're using Drupal only for your main website (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.