Web SDK Reference

Install and configure the Affclix tracking SDK. Covers click tracking, impression tracking, conversion firing, custom events, UTM attribution, consent management, and bot detection.

Quick Start

Add the SDK snippet inside <head> or just before </body>.

HTML
<script src="https://assets.affclix.com/sdk/v3/affclix-sdk.min.js"></script>
<script>
  AffclixSDK.init({
    trackingDomain: 't.yourdomain.com',
    cookieDomain:   '.yourdomain.com',
    debug:          false
  });
</script>
Your workspace is identified by the hostname

trackingDomain is a bare hostname — your workspace subdomain (acme.affclix.org) or a white-label CNAME (t.yourdomain.com). Since v3 the SDK never sends a tenant ID: the tracking server resolves your workspace from the hostname, exactly like Affise, Trackier, and Everflow. The legacy ?d= query parameter and the domainID option are deprecated and only kept for pre-v3 installs.

Init Configuration

All options passed to AffclixSDK.init(). Only trackingDomain is required.

OptionTypeDefaultDescription
trackingDomainstringlocation.hostnameBare tracking hostname (no https://) — your workspace subdomain or white-label CNAME. Identifies your workspace; no tenant ID parameter is sent
cookieDomainstringauto-detected root domainCookie scope — defaults to the page root domain for cross-subdomain tracking
cookieExpirynumber30Attribution cookie lifetime in days
clickExpirynumber30Click-ID attribution window in days
cookielessbooleanfalseEnable canvas/hardware fingerprint fallback
crossDomainTrackingbooleanfalseAppend visitor/click params to outbound links listed in crossDomainDomains
crossDomainDomainsstring[][]Domains eligible for cross-domain link decoration
consentRequiredbooleanfalseGDPR gate — queue all tracking until consent.grant() is called
respectDNTbooleanfalseDisable tracking when the browser sends Do Not Track
useGoogleTransparencybooleanfalseGoogle Click Transparency URL format — requires clientId
clientIdstringnullGoogle Transparency client ID (required when useGoogleTransparency is on)
debugbooleanfalseVerbose console logging
testModebooleanfalseMarks conversions with a test flag
domainIDnumber—DEPRECATED — pre-v3 tenant ID; ignored when trackingDomain identifies your workspace

Track a Click

Call trackClick() when a visitor clicks an affiliate link.

JavaScript
AffclixSDK.trackClick({
  campaignID:  '112792',
  affiliateID: '26377765',
  creativeID:  '4521',                      // optional — numeric creative ID
  redirectURL: 'https://offer.example.com'  // optional — navigate after tracking
}).then(function(response) {
  console.log('Click ID:', response.clickId);
});

Track an Impression

Fire an impression pixel when a banner or creative is viewed. Useful for CPM campaigns. creativeID is the numeric ID of the creative as listed in your dashboard creative library.

JavaScript
AffclixSDK.trackImpression({
  campaignID:  '112792',
  affiliateID: '26377765',
  creativeID:  '4521'
});

Track a Conversion

Fire on your thank-you / order-confirmation page. Pass order details for accurate revenue reporting.

JavaScript
AffclixSDK.trackConversion({
  campaignID: '112792',
  eventName:  'purchase',
  conversionData: {
    txn_id:   'ORDER-1001',
    sale:     '99.00',
    currency: 'USD',
    coupon:   'SAVE10'
  }
}).then(function(response) {
  console.log('Transaction:', response.transactionId);
});
Deduplication

Always pass a unique txn_id (your order ID). Conversions with an identical transaction ID are suppressed for 30 days, matching the standard on Affise, Trackier, and HasOffers. The stored click ID is attached automatically — with promo-code and view-through fallback when no click is present.

Custom Events

Track any funnel step — add-to-cart, trial start, lead form — with trackEvent().

JavaScript
AffclixSDK.trackEvent('add_to_cart', {
  productId: 'SKU-42',
  value:     49.00,
  currency:  'USD'
});

AffclixSDK.trackEvent('lead', {
  formId: 'contact-form',
  source: 'landing-page-hero'
});

UTM & Attribution

On page load the SDK reads and persists all recognised parameters: utm_source, utm_medium, utm_campaign, utm_content, utm_term, gclid, fbclid, ttclid, sclid, and click_id.

JavaScript
var utm     = AffclixSDK.getUTMParams();   // { utm_source: 'newsletter', utm_campaign: 'summer-sale', ... }
var adIds   = AffclixSDK.getAdClickIds();  // { gclid: 'Cj0KCQj...', fbclid: '', ttclid: '', sclid: '' }
var clickId = AffclixSDK.getClickId();     // 'ck_abc123'
var ref     = AffclixSDK.getReferrer();    // { type: 'organic', source: 'google', url: '...' }

var attr = AffclixSDK.getAttribution();
// returns:
// {
//   model:      'last_click',
//   firstTouch: { ts: 1721030400000, params: { utm_source: 'newsletter' }, landing: '...' },
//   lastTouch:  { ts: 1721203200000, params: { utm_source: 'meta' },       landing: '...' }
// }

Bot Detection

Bot detection is always on: the SDK suppresses events from headless browsers (Puppeteer, Selenium, Playwright), known crawler user-agents, webdriver-flagged sessions, and audit tools like Lighthouse. Blocked calls resolve with a blocked status instead of hitting your tracking server.

JavaScript
AffclixSDK.trackClick({ campaignID: '112792' }).then(function(res) {
  if (res.status === 'blocked') {
    console.log('Suppressed:', res.reason); // 'bot'
  }
});
Rate this article
★★★★★
Thanks for rating!

Was this article helpful?