Ecommerce
Add Loogika to BigCommerce
You add Loogika to a BigCommerce store through Script Manager in the control panel. Script Manager places the tag on every storefront page, and you do not edit the theme. A second script in the same place sends a purchase event from the order confirmation page.
Last updated .
What do you need before you start?
Copy your script tag from Site Settings in Loogika, under the Tracking Script tab. It looks like this, with your own 12-character site ID in place of YOUR_SITE_ID:
<script src="https://app.loogika.com/api/script.js?siteId=YOUR_SITE_ID" defer></script>
How do you add Loogika with Script Manager?
Create one script that loads in the head of all pages. Script Manager adds it to the storefront for you, so no theme file changes.
- In the control panel, go to Storefront, then Script Manager, and click Create a Script.
- Give the script a name, for example Loogika Analytics.
- Set Placement to Head and Location to All pages.
- Set Script category to Analytics and Script type to Script.
- Paste the tag into Script contents and click Save.
Can you add the tag to the theme files instead?
Yes. The tag also works when you paste it into the head.html file of your theme. Back up the theme before you edit its files.
- Go to Storefront, then Themes. Click Advanced on your current theme and choose Edit Theme Files.
- Open the folders templates, components and common, and then the file
head.html. - Paste the tag at the end of the file, just before the closing
</head>tag, and click Save.
How do you track purchases in BigCommerce?
Create a second script in Script Manager that runs only on the order confirmation page. Set Placement to Footer, Location to Order Confirmation and Script type to Script, and paste the code below.
<script>
(function () {
function waitForLoogika(callback, timeout) {
var start = Date.now();
(function check() {
if (window.loogika && typeof window.loogika.event === 'function') {
callback();
} else if (Date.now() - start < timeout) {
setTimeout(check, 100);
}
})();
}
waitForLoogika(function () {
{{#if checkout.order}}
window.loogika.event('purchase', {
transaction_id: '{{checkout.order.id}}',
value: {{checkout.subtotal.value}},
currency: '{{checkout.currency.code}}'
});
{{/if}}
}, 5000);
})();
</script>
BigCommerce runs the contents of a Script Manager script through Handlebars, its template language. Expressions such as checkout.order.id are replaced with the real order data before the page reaches the browser.
The waitForLoogika function checks every 100 milliseconds whether the tracking script has loaded, for up to five seconds. The purchase event is then sent even when the footer script runs before the tag in the head.
How do you check that Loogika is installed?
Open your storefront in another tab and visit a few products. The pageviews show up in the Loogika dashboard within a few seconds.
If nothing arrives, open the page source and look for script.js?siteId=. The script troubleshooting page covers ad blockers and the other common causes.
Why does BigCommerce not send data to Loogika?
| Symptom | Fix |
|---|---|
| The tag is missing from the page source | Check that Script Manager lists the script as enabled. After that, go to Server Settings, then Store-level caching, and click Purge cache |
| Pageviews arrive, but no purchase event | Check that the purchase script uses the Order Confirmation location. Place a test order to confirm that the event arrives |
The Handlebars objects checkout.order, checkout.subtotal and checkout.currency depend on the checkout version of your BigCommerce store. A test order is the reliable way to see whether your store fills them in.