OnyxMetric
Integration Guides

BigCommerce

Add OnyxMetric analytics to your BigCommerce store

BigCommerce's Script Manager adds scripts to every storefront page without theme edits. It is also where the order-confirmation purchase event goes. Editing the theme's head.html works too.

Copy your tracking snippet

In OnyxMetric, open your site's Site Settings and copy the tracking script. It looks like this:

<script src="https://app.onyxmetric.com/api/script.js?siteId=YOUR_SITE_ID" async></script>

YOUR_SITE_ID is the numeric ID of your site.

Add the snippet to BigCommerce

  1. In the control panel, go to Storefront > Script Manager and click Create a Script.
  2. Fill in the settings:
    • Name: OnyxMetric Analytics
    • Placement: Head
    • Location: All pages
    • Script category: Analytics
    • Script type: Script
  3. Paste the snippet into Script contents and click Save.

Back up your theme before editing files.

  1. Go to Storefront > Themes, click Advanced on your current theme, then Edit Theme Files.
  2. Open templates > components > common > head.html.
  3. Paste the snippet at the end, before the closing </head> tag, and click Save.

Check that it works

Load your live site and click through a few pages. Pageviews show up in the OnyxMetric dashboard within seconds.

If nothing arrives:

  • View the page source and search for script.js?siteId= to confirm the tag is present.
  • In the browser's Network tab, check that script.js returns 200 and that requests go to /api/track.
  • Turn off ad blockers, or proxy the script through your own domain.
  • Read script troubleshooting for other causes.

Track purchases

Create a second script in Script Manager with Placement: Footer, Location: Order Confirmation, and Script type: Script. BigCommerce runs Script Manager contents through Handlebars, so expressions such as checkout.order.id are filled in with real order data:

<script>
(function () {
  function waitForOnyx(callback, timeout) {
    var start = Date.now();
    (function check() {
      if (window.onyx && typeof window.onyx.event === 'function') {
        callback();
      } else if (Date.now() - start < timeout) {
        setTimeout(check, 100);
      }
    })();
  }

  waitForOnyx(function () {
    {{#if checkout.order}}
    window.onyx.event('purchase', {
      transaction_id: '{{checkout.order.id}}',
      value: {{checkout.subtotal.value}},
      currency: '{{checkout.currency.code}}'
    });
    {{/if}}
  }, 5000);
})();
</script>

waitForOnyx polls until the tracking script from the head has defined window.onyx, so the event is not lost if the confirmation page runs the footer script first.

Troubleshooting

  • Script not on the page: confirm it is enabled in Script Manager, then purge the cache under Server Settings > Store-level caching > Purge cache.
  • Purchase event missing: the script must use the Order Confirmation location. The checkout.order, checkout.subtotal, and checkout.currency objects depend on your checkout version, so place a test order to confirm the event arrives.

Next steps

On this page