Event Tag & Personalisation
Out of the box, some events mentioned in Event Tag will be tracked. In addition to that, events for View Product, Add to cart and Purchase need to be implemented using Customer Events.
In Shopify admin:
- Go to Settings > Customer events.
- Choose Add custom pixel.
- Give it a name and copy the example below in the Code section.
- Update the INSTANCE_KEY on line 11 to your specific instancekey.
// bootstrap event tag
(function(w, d, l, i, u) {
w._twa = l;w[l] = w[l] || [];
w[l].push({ 'twa.start': new Date().getTime(), event: 'twa.js' });
w[l].push({ 'twa.instance': i, event: 'twa.init' });
var f = d.getElementsByTagName('script')[0], j = d.createElement('script');
j.async = true;j.src = u;
f.parentNode.insertBefore(j, f);
})(window, document, 'tweakwiseLayer', 'INSTANCE_KEY', "https://navigator-analytics.tweakwise.com/bundles/scout.js");
analytics.subscribe("item_click", function(event){
if(!tweakwiseLayer) {
console.log('tweakwise - layer not present')
return;
}
console.log('tweakwise - product clicked', event)
tweakwiseLayer.push({
event: 'itemClick',
data: event.customData
});
})
analytics.subscribe("product_viewed", function (event) {
tweakwiseLayer.push({
event: 'productView',
data: {
productKey: event.data.productVariant.id
}
});
})
analytics.subscribe("product_added_to_cart", function (event) {
tweakwiseLayer.push({
event: 'addtocart',
data: {
productKey: event.data.cartLine?.merchandise.id,
quantity: event.data.cartLine?.quantity,
totalAmount: event.data.cartLine?.cost.totalAmount.amount,
}
});
})
analytics.subscribe("checkout_completed", function (event) {
tweakwiseLayer.push({
event: 'purchase',
data: {
productKeys: event.data.checkout.lineItems.map(o => o.variant.id),
revenue: event.data?.checkout?.totalPrice?.amount
}
});
});Important:
- The used id's (for example on line 43 for the purchase) can be different, depending on your product configuration. These should be the productid that is known to Tweakwise.
- Check the feed generation what value should be used here.
- Use the pixel debugger to check the data samples in order to map the correct product ids.
Event Tag adoption
| Feature | Support |
|---|---|
| SessionStart | ✅ |
| PageView | ✅ |
| PageImpression | ✅ |
| ItemClick | ✅ |
| AddToCart | ✅ |
| AddToWishlist | ⚠️ (customization on wishlist plugin) |
| Purchase | ✅ |
| Search | ✅ |
Updated 1 day ago
Did this page help you?