Ecommerce
Add Loogika to Ecwid
Where the Loogika tag goes depends on how your Ecwid by Lightspeed store runs. On an Ecwid Instant Site you paste the tag into the header code setting. When the store is embedded in a page on another platform, the tag goes into the head of that host site.
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>
Instant Site accepts custom code on three plans, which are Venture, Business and Unlimited. On the free Starter plan the custom code fields are missing.
How do you add Loogika to an Ecwid Instant Site?
Paste the tag into the header code field under SEO settings. The setting has no separate publish step.
- From your Ecwid admin, go to Website. You can also go to Overview and click Manage Instant Site.
- Further down, find SEO settings. Under Header meta tags and site verification, click Add Code.
- Paste the tag and save.
- Reload your Instant Site in the browser.
Under Advanced website settings, the same page offers a field named Custom JavaScript code. The tag works there too. That field prints its code where the body ends, so we recommend the header field.
How do you add Loogika to an embedded Ecwid store?
The site that hosts the store needs the tag in its head. Use the method that platform offers. Ecwid draws the storefront inside your own page with its embed script, and the tag on that page tracks it. The install guides cover WordPress, Wix, Squarespace, Webflow and other platforms.
One tag covers the whole embedded store. The host page stays the same while Ecwid draws product pages, the cart and the checkout inside it.
How do you track purchases in Ecwid?
Ecwid has a storefront JavaScript API that calls Ecwid.OnOrderPlaced right after a customer places an order. Inside that call you can send a purchase event that carries the order number and the totals.
<script>
Ecwid.OnAPILoaded.add(function () {
Ecwid.OnOrderPlaced.add(function (order) {
window.loogika?.event('purchase', {
transaction_id: order.vendorNumber,
value: order.total,
tax: order.tax,
shipping: order.shipping
});
});
});
</script>
The code only works when the Ecwid object exists before it runs. On Instant Site, paste it into Custom JavaScript code under Advanced website settings. On an embedded store, the host page must load the Ecwid embed script first and your code after it.
Customers find the order number in their emails, and the order data calls that value vendorNumber. The field orderNumber is the internal ID that Ecwid uses.
Can you track the purchase on the order confirmation page instead?
Yes. Ecwid has a field called Custom tracking code on Order Confirmation page. Go to Settings, then General, then Tracking & Analytics. The field needs the same plans as custom code on Instant Site.
Code in that field runs on the /checkout/order-confirmation page. It can read the template variables of Ecwid when you wrap it in <#noescape>:
<script>
<#noescape>
document.addEventListener('DOMContentLoaded', function () {
window.loogika?.event('purchase', { transaction_id: "${order.number}", value: ${order.total} });
});
</#noescape>
</script>
Use one of the two purchase methods, not both. With both in place, Loogika counts every order twice.
How do you check that Loogika is installed?
Open your store 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=.
Why does Ecwid not send data to Loogika?
| Symptom | Fix |
|---|---|
| SEO settings show no Add Code button | The store uses the Starter plan, and custom code requires Venture or a higher plan |
The console says Ecwid is not defined | The purchase code ran before the Ecwid script. Place the code after the embed script. On Instant Site, the Custom JavaScript code field is the right place for it |
| An embedded store shows no pageviews | The tag belongs on the host site, not in Ecwid. Search the source of the host page for script.js?siteId= |