Skip to main content
tapfiliate.js detects visitors who come through affiliate links and reports their sign-ups and purchases. It only needs your account ID, which is public, so it is safe to use in the browser.
Using a shop or billing platform? Check the integrations in the help center first: most of them set this up for you.

Setup

Add the snippet to every page of your site, so a click is recorded wherever the visitor lands:
Then call conversion, customer, trial or lead on the page where the sale or sign-up happens. Calls are queued, so they work before the script has loaded. These calls only reach Tapfiliate when the visitor came through an affiliate within the program’s cookie time. For everyone else nothing is sent, so the code can stay on the page for all visitors.

create

Initializes tapfiliate.js.

detect

Looks for affiliate tracking parameters in the URL. If it finds them, it records a click and sets a cookie, so a later conversion is attributed to the affiliate. Without tracking parameters it makes no request.

conversion

Tracks a conversion, usually a purchase. Put it on your thank-you page.

conversionMulti

Tracks one conversion with several commissions, for example a different rate per product category.
options is the same as for conversion. commissions is an array with one object per commission:

customer, trial and lead

Track a customer when a referred visitor signs up, before they pay. Conversions you track later for the same customer_id are attributed to the same affiliate.
trial and lead work like customer and set the customer’s initial status to trial or lead. Use trial for SaaS and subscriptions, lead for lead generation and long sales cycles.

click

For standard setups use detect. click is for rare cases where you know the affiliate from your own data, for example a list of referring domains.
Records a click from tracking parameters you pass explicitly.
trackingParameters holds either a referral code or an asset ID and source ID, for example { referral_code: 'janejameson' } or { asset_id: '1-abcdef', source_id: '2-cdefgh' }. The only option is always_callback.

Callbacks

By default the callbacks of detect, conversion, conversionMulti, customer and click fire only on success. Pass always_callback: true in the options to get every outcome, with the conventional signature:

Several sites

To track one program across several sites, create a program group per site, assign the program to it and pass the group in the conversion: