Data collection is switched off until we enable it for your shop. Contact us before you start testing.
Helper function to avoid a loading race
Copy this helper into your page before you call any tracking function, and wrap every call in it:Logged-in customer
CalllinkCustomer on page load whenever a customer is logged in:
- send only your internal customer id, never an email, phone number, name, or anything else that identifies a person
- calling it on every page is fine, it only forwards when the id changes
Line items
A line item is one product in the cart or in the order, with how many the shopper took and at what price.setCart and trackPurchase both take a lines array of them.
Each line item must say which product it is, with at least one of url, sku, gtin or variantId. The value must match your product feed character for character, because we use it to find the product in our catalog.
Cart
CallsetCart on every page load and after every cart change: add, remove, or quantity change. Always send the whole cart, not only the item that changed. An emptied cart is lines: [], and please send it too.
- calling it on every page is fine, it only forwards when the cart changes
Purchase
CalltrackPurchase on the order confirmation page, once the order is really confirmed.
- run it on every load of the confirmation page, an identical repeat is not sent again and we also deduplicate by
orderId totaldoes not have to equal the sum of the lines, discounts, shipping and tax can make them differ
Field rules
A call that breaks these rules is rejected.Checking that it works
Open the browser’s DevTools console and typeMolin: tracking error into its filter box. If you see no errors, the calls work.
If a call is wrong, the message names the call and the field to fix, for example Molin: tracking error - setCart was not sent followed by lines.0.price for the first line’s price.
If the message ends with because storefront events are disabled for this widget, we have not switched data collection on for your shop yet. Contact us to enable it.