Know what must work before you launch
Connect a sitewide Drupal library to a checkout path you can verify
- Best fit
- Teams evaluating AffiliateBase for a Drupal affiliate workflow.
- Checkout handoff
- The checkout path must receive the generated AffiliateBase referral ID.
- Proof required
- Complete one referred checkout and confirm the attributed sale and commission.
Follow the attribution evidence
Illustrative scenario · fictional values
-
Referred visit
?via=partner
AffiliateBase captures the visit and generates a referral record.
-
Checkout handoff
referral ID
The checkout must carry the generated identifier into Stripe.
-
Paid event
$99 paid
A supported Stripe event confirms the attributed payment.
-
Commission
$19.80 due
An eligible attributed sale creates the commission record.
-
Payout prep
Payout ready
Review the commission and prepare the next step with your payout provider.
This guide is for Drupal merchants building a program for their own customers and partners. Add AffiliateBase as a sitewide browser library on the landing and checkout-start pages; do not rely on an administrator-only page or cached markup that omits the script.
Drupal Commerce and payment modules control checkout. Their use of Stripe does not automatically pass AffiliateBase’s generated referral ID, so module-level compatibility remains unverified until the completed Stripe object contains it.
Use a same-page Stripe Payment Link or a custom Checkout Session you control, then follow the Stripe affiliate program guide and verification checklist.
Follow these steps to integrate AffiliateBase with your Drupal site:
Add the Tracking Script
Add the AffiliateBase tracking script to your Drupal site. You can add it via your theme's html.html.twig template or using a module like "Asset Injector".
Use the pinned jsDelivr tracking URL for the latest published AffiliateBase release.
<script async src="https://app.affiliatebase.io/track.js" data-account-id="YOUR_ACCOUNT_ID"></script>Add via Theme Template
Alternatively, add the script directly to your Drupal theme's html.html.twig file before the closing </head> tag.
{# In your theme's html.html.twig, before </head> #}
<script>(function(w,r){w._abq=w._abq||[];w[r]=w[r]||function(){(w[r].q=w[r].q||[]).push(arguments)}})(window,'affiliatebase');</script>
<script async src="https://app.affiliatebase.io/track.js" data-account-id='YOUR_ACCOUNT_ID'></script>Use Stripe Payment Links or Buttons (Optional)
If you're using Stripe Payment Links or Buy Buttons on your Drupal site, add the tracking script on the same page so AffiliateBase can pass the generated referral ID.
<!-- Keep Stripe checkout elements on the same page as the AffiliateBase script. -->
<a href="https://buy.stripe.com/xxxxx">Buy now</a>
<stripe-pricing-table
pricing-table-id="prctbl_xxx"
publishable-key="pk_live_xxx"
></stripe-pricing-table>
<!-- For custom or redirected Stripe-hosted links, opt in explicitly. -->
<a data-affiliatebase href="https://link.payment/xxxxx">Buy now</a>Integrate with Drupal Commerce (Advanced)
For Drupal Commerce, capture the referral ID at checkout and pass it to Stripe.
<?php
// modules/custom/affiliatebase/affiliatebase.module
use Drupal\Core\Form\FormStateInterface;
/**
* Implements hook_form_alter().
*/
function affiliatebase_form_alter(&$form, FormStateInterface $form_state, $form_id) {
// Add to checkout forms
if (strpos($form_id, 'commerce_checkout') !== FALSE) {
$form['#attached']['library'][] = 'affiliatebase/tracking';
// Add hidden field for referral ID
$form['affiliatebase_referral'] = [
'#type' => 'hidden',
'#attributes' => ['id' => 'affiliatebase-referral'],
];
// JavaScript to populate the hidden field
$form['#attached']['html_head'][] = [
[
'#tag' => 'script',
'#value' => 'document.addEventListener("DOMContentLoaded", function() {
var field = document.getElementById("affiliatebase-referral");
if (field && window.AffiliateBase?.referral) {
field.value = window.AffiliateBase?.referral;
}
});',
],
'affiliatebase_checkout',
];
}
}Test Your Integration
Visit your Drupal site with a test affiliate link and verify tracking is working.
// Visit your site with a test affiliate link:
// Open the exact setup-test link shown in AffiliateBase.
// Open browser console and check:
console.log(window.AffiliateBase?.referral); // Should show a generated referral IDWhy Use AffiliateBase with Drupal?
Drupal can host the referral script; payment compatibility depends on the exact commerce and Stripe path.
Simple Script Installation
Add a single script tag via theme template or Asset Injector module.
Commerce Integration
Drupal Commerce requires a custom or documented handoff that puts the generated referral ID on the Stripe payment path.
Stripe Integration
Track conversions from Stripe Payment Links, Buy Buttons, and checkout.
Enterprise Ready
Scalable solution perfect for enterprise Drupal deployments.
Frequently Asked Questions
Does AffiliateBase work with Drupal Commerce?
Do I need a custom module for AffiliateBase?
How do I add the script without editing templates?
What tracking parameters does AffiliateBase support?
Related platform guides
Create an Affiliate Program with WordPress
Install AffiliateBase on WordPress, choose a supported Stripe checkout, and verify referral attribution without assuming WooCommerce or plugin compatibility.
Create an Affiliate Program with Webflow
Add affiliate tracking to a published Webflow site, pair it with a supported Stripe checkout, and verify referral attribution before launch.
Create an Affiliate Program for Your Squarespace Site
Review Squarespace code-injection prerequisites, compatible Stripe checkout options, native-commerce limits, and AffiliateBase verification steps.
Ready to Launch Your Drupal Affiliate Program?
Get started with AffiliateBase today and start growing your Drupal site with affiliate marketing.