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 handoff guide and verification checklist.
Follow these steps to integrate AffiliateBase with your Drupal site:
Add the Tracking Script
<script async src="https://app.affiliatebase.io/track.js" data-account-id="YOUR_ACCOUNT_ID"></script>
Add via Theme Template
{# 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)
<!-- 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)
<?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 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 ID
Why 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
Add an Affiliate Program to Next.js
Install affiliate tracking in Next.js, hand the generated referral ID to a server-created Stripe Checkout Session, and verify attribution.
Add an Affiliate Program to Nuxt
Load affiliate tracking in Nuxt, pass the generated referral ID to a server route, and verify a Stripe sale and commission.
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.
Add Affiliate Tracking to a React Checkout
Capture affiliate referrals in a React app, send the generated referral ID to your checkout backend, and verify Stripe attribution.
Ready to Launch Your Drupal Affiliate Program?
Get started with AffiliateBase today and start growing your Drupal site with affiliate marketing.