Overview
Affclix tracks Shopify purchases through a layered detection strategy:
- Shopify Analytics API — primary method; reads ShopifyAnalytics.lib.page() and order metadata
- dataLayer push — fallback for headless / custom themes using GTM
- Alternative checkouts — GoKwik, ShipRocket, Razorpay event listeners
Prerequisites
- Shopify store with theme file access (Online Store 2.0 or legacy)
- Affclix account with tracking domain configured
- Additional Scripts permission for Checkout Extensibility (Plus plans)
Installation
Add the snippet to your theme.liquid file inside the <head> tag. For Shopify Plus also add to checkout.liquid.
Open your theme editor
Go to Online Store → Themes → Actions → Edit code.
Open theme.liquid
Find the file under Layout → theme.liquid.
Paste the SDK snippet
Add the code below just before the closing </head> tag.
How It Works
Shopify Detection
SDK detects window.ShopifyAnalytics and reads page metadata, shop currency, and cart token.
Analytics API
If present, ShopifyAnalytics.lib.page() provides order data without relying on Liquid variables — useful for headless setups.
dataLayer Fallback
If Analytics API is unavailable, the SDK listens for a purchase event on window.dataLayer (standard GTM e-commerce schema).
Conversion Fired
Order data is normalised and posted to your Affclix postback endpoint. Duplicate orderId values within 24 h are automatically suppressed.
Alternative Checkouts
For Indian Shopify stores using third-party checkout providers, map the provider payload with getCheckoutData() inside the provider success callback, then fire trackConversion().
GoKwik
// Inside your GoKwik order-success callback:
var data = AffclixSDK.integrations.shopify.getCheckoutData(event, 'gokwik');
AffclixSDK.trackConversion({
campaignID: 'YOUR_CAMPAIGN_ID',
eventName: 'purchase',
conversionData: data
}); ShipRocket Checkout
var data = AffclixSDK.integrations.shopify.getCheckoutData(event, 'shiprocket');
AffclixSDK.trackConversion({
campaignID: 'YOUR_CAMPAIGN_ID',
eventName: 'purchase',
conversionData: data
}); Razorpay Magic Checkout
var data = AffclixSDK.integrations.shopify.getCheckoutData(event, 'razorpay');
AffclixSDK.trackConversion({
campaignID: 'YOUR_CAMPAIGN_ID',
eventName: 'purchase',
conversionData: data
}); When a provider is specified, the SDK attaches a postMessage listener to the checkout iframe. No manual order data mapping is required.
Conversion Fields
| Field | Type | Required | Description |
|---|---|---|---|
orderId | string | Yes | Unique order number for deduplication |
revenue | number | Yes | Order total (excluding shipping unless desired) |
currency | string | No | ISO 4217 code — defaults to store currency |
coupon | string | No | Discount code applied at checkout |
items | array | No | Line items for product-level commission rules |
provider | string | No | Alternative checkout: gokwik, shiprocket, razorpay |
Testing
Enable testMode so conversions are recorded with an isTest flag and will not credit any affiliate.
AffclixSDK.init({
trackingDomain: 't.yourdomain.com',
testMode: true
}); The SDK checks order.created_at and will not fire a conversion if the order is more than 2 hours old. This prevents duplicate fires on page reloads of the confirmation page.