Ecwid
Add OnyxMetric analytics to your Ecwid store
An Ecwid by Lightspeed store runs either on Ecwid's hosted Instant Site or embedded in a page on another platform. On Instant Site the tag goes into the site's header code setting. For an embedded store, it goes into the <head> of the host site.
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 Ecwid
Custom code on Instant Site needs the Venture, Business, or Unlimited plan. The free Starter plan has no custom code fields.
- From your Ecwid admin, go to Website (or Overview → Manage Instant Site).
- Scroll to SEO settings and click Add Code under Header meta tags and site verification.
- Paste the snippet and save.
- Reload your Instant Site. This setting has no separate publish step.
The Custom JavaScript code field under Advanced website settings also works, but it prints at the end of <body>, so prefer the header field.
Ecwid's embed script renders the store inside your own page, so add the snippet to the <head> of the host site using that platform's method. See the integration guides for WordPress, Wix, Squarespace, Webflow, and others.
One snippet covers the whole store, because product pages, cart, and checkout render inside the same host page.
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.jsreturns200and 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
Ecwid's storefront API fires Ecwid.OnOrderPlaced right after a customer places an order. Add this where the Ecwid object already exists: on Instant Site, under Advanced website settings → Custom JavaScript code; on an embedded store, below the Ecwid embed script.
<script>
Ecwid.OnAPILoaded.add(function () {
Ecwid.OnOrderPlaced.add(function (order) {
window.onyx.event('purchase', {
transaction_id: order.vendorNumber,
value: order.total,
tax: order.tax,
shipping: order.shipping,
items: order.items.map(function (item) {
return { item_id: item.sku, item_name: item.name, price: item.price, quantity: item.quantity };
})
});
});
});
</script>vendorNumber is the order number customers see in emails. orderNumber is Ecwid's internal ID. Event properties are capped at 2048 characters of JSON, so trim items to ID, quantity, and price, or drop it, for large orders.
Ecwid also offers a Custom tracking code on Order Confirmation page field under Settings → General → Tracking & Analytics. Use one method or the other, never both, or every order is counted twice.
Troubleshooting
- No Add Code button under SEO settings: the store is on Starter. Custom code needs Venture or higher.
Ecwid is not defined: the purchase script ran before Ecwid's script. Move it below the embed, or use the Instant Site Custom JavaScript code field, which runs at the end of the page.- Embedded store, no pageviews: the snippet belongs to the host site, not to Ecwid. Check the host page's source for
script.js?siteId=.
Next steps
- Track custom events such as signups, purchases, and clicks.
- Identify users to tie sessions to accounts.
- Proxy the script through your own domain to get past ad blockers.
- Script attributes let you skip or mask URLs and tag events.