BigCommerce Integration

Track affiliate conversions on BigCommerce via Analytics.js, the BCData global object, or dataLayer. Headless Next.js storefronts are supported via server-to-server postback.

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.

01

Open Script Manager

In BigCommerce Admin go to Storefront → Script Manager → Create a Script.

02

Configure the script

Set Location to Footer, Pages to All Pages, Script Category to Analytics.

03

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.

JavaScript
<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.

JavaScript
<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>
Auto-detect mode

Omitting the method key causes the SDK to try Analytics.js first, fall back to BCData, then fall back to dataLayer automatically.

Tracked Fields

FieldBC SourceDescription
orderIdBCData.order_idUnique order reference for deduplication
revenueBCData.order_totalGrand total in store currency
currencyBCData.currency_codeISO 4217 currency code
couponBCData.coupon_codeDiscount code applied at checkout
utk_click_idCookie / localStorageAffclix 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:

JavaScript (Next.js)
// 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!
; }
S2S Postback recommended for headless

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.

Rate this article
★★★★★
Thanks for rating!

Was this article helpful?