Overview
BigCommerce exposes order data through three surfaces the SDK can consume:
- Analytics.js — BigCommerce's native analytics library, available on all Stencil themes
- BCData — a server-rendered JS global containing order metadata on the order-confirmation page
- dataLayer — GTM enhanced e-commerce purchase event, available if you have GTM installed
Installation
Add the SDK via BigCommerce Script Manager to inject it on all storefront pages.
Open Script Manager
In BigCommerce Admin go to Storefront → Script Manager → Create a Script.
Configure the script
Set Location to Footer, Pages to All Pages, Script Category to Analytics.
Paste the snippet
Use Method 1 or Method 2 from below.
Tracking Methods
Method 1 — Analytics.js (recommended)
The SDK hooks into BigCommerce's Analytics library. Most reliable for standard Stencil themes.
<script src="https://assets.affclix.com/sdk/v3/affclix-sdk.min.js"></script>
<script>
AffclixSDK.init({
trackingDomain: 't.yourdomain.com',
cookieDomain: '.yourdomain.com'
});
// Listens on Segment analytics 'Order Completed' — with BCData and
// DataLayer fallbacks handled automatically by the same init call.
AffclixSDK.integrations.bigcommerce.init({
campaignID: 'YOUR_CAMPAIGN_ID',
autoTrack: true
});
</script> Method 2 — BCData Object
Reads order data directly from the server-rendered BCData global on the confirmation page.
<script src="https://assets.affclix.com/sdk/v3/affclix-sdk.min.js"></script>
<script>
AffclixSDK.init({
trackingDomain: 't.yourdomain.com',
cookieDomain: '.yourdomain.com'
});
// Same init call — on the confirmation page the SDK reads the
// server-rendered BCData order object automatically when autoTrack is on.
AffclixSDK.integrations.bigcommerce.init({
campaignID: 'YOUR_CAMPAIGN_ID',
autoTrack: true
});
</script> Omitting the method key causes the SDK to try Analytics.js first, fall back to BCData, then fall back to dataLayer automatically.
Tracked Fields
| Field | BC Source | Description |
|---|---|---|
orderId | BCData.order_id | Unique order reference for deduplication |
revenue | BCData.order_total | Grand total in store currency |
currency | BCData.currency_code | ISO 4217 currency code |
coupon | BCData.coupon_code | Discount code applied at checkout |
utk_click_id | Cookie / localStorage | Affclix attribution ID from landing click |
Headless BigCommerce
For Next.js or other headless storefronts connected via the BigCommerce Storefront API, BCData is not available. Use server-to-server postback or fire the SDK conversion manually:
// pages/order-confirmation.js
import { useEffect } from 'react';
export default function OrderConfirmation({ order }) {
useEffect(function() {
if (typeof window !== 'undefined' && window.AffclixSDK) {
window.AffclixSDK.trackConversion({
orderId: order.id,
revenue: order.totalPrice,
currency: order.currencyCode,
coupon: order.discountCode || ''
});
}
}, [order.id]);
return Thank you for your order!;
} For headless storefronts, server-to-server postback from your API route is more reliable than client-side tracking. See the S2S Postback guide for the full implementation.