Quick Start
Add the SDK snippet inside <head> or just before </body>.
<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> 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.
| Option | Type | Default | Description |
|---|---|---|---|
trackingDomain | string | location.hostname | Bare tracking hostname (no https://) — your workspace subdomain or white-label CNAME. Identifies your workspace; no tenant ID parameter is sent |
cookieDomain | string | auto-detected root domain | Cookie scope — defaults to the page root domain for cross-subdomain tracking |
cookieExpiry | number | 30 | Attribution cookie lifetime in days |
clickExpiry | number | 30 | Click-ID attribution window in days |
cookieless | boolean | false | Enable canvas/hardware fingerprint fallback |
crossDomainTracking | boolean | false | Append visitor/click params to outbound links listed in crossDomainDomains |
crossDomainDomains | string[] | [] | Domains eligible for cross-domain link decoration |
consentRequired | boolean | false | GDPR gate — queue all tracking until consent.grant() is called |
respectDNT | boolean | false | Disable tracking when the browser sends Do Not Track |
useGoogleTransparency | boolean | false | Google Click Transparency URL format — requires clientId |
clientId | string | null | Google Transparency client ID (required when useGoogleTransparency is on) |
debug | boolean | false | Verbose console logging |
testMode | boolean | false | Marks conversions with a test flag |
domainID | number | — | DEPRECATED — pre-v3 tenant ID; ignored when trackingDomain identifies your workspace |
Track a Click
Call trackClick() when a visitor clicks an affiliate link.
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.
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.
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);
}); 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().
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.
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: '...' }
// } Consent Management
Integrate with your CMP (Cookiebot, OneTrust, Axeptio) using the consent API.
// Enable the consent gate at init — all tracking is queued until granted
AffclixSDK.init({
trackingDomain: 't.yourdomain.com',
consentRequired: true
});
// In your CMP accept-callback:
AffclixSDK.consent.grant(['marketing', 'analytics']);
// Revoke a category, or wipe everything:
AffclixSDK.consent.revoke('marketing');
AffclixSDK.consent.revokeAll();
var ok = AffclixSDK.consent.hasConsent('marketing'); If operating in the EU, set consentRequired: true. Clicks, impressions, and conversions fired before consent are queued in memory and replayed automatically once consent.grant() is called — nothing is stored or sent beforehand.
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.
AffclixSDK.trackClick({ campaignID: '112792' }).then(function(res) {
if (res.status === 'blocked') {
console.log('Suppressed:', res.reason); // 'bot'
}
});