Out of the box search and click product events will be tracked. In addition to that, events for View Product & Purchase need to be implemented.
View product
To measure how many times item details are viewed, send a productView
event whenever a user views an item’s details screen.
The snippet usually is placed in sections/main-product.liquid:
tweakwiseLayer.push({
event: 'productView',
data: {
productKey: '{{product.id}}'
}
});
Note: the productKey should be the productid that is known to Tweakwise. Check the feed generation what value should be used here.
Purchase
The purchase
event tracks the transaction of your customers. It is crucial for analyzing the performance of A/B tests, builder, filter templates and more.
This snippet usually is placed on the thank-you page. Go to Settings > Customer events in Shopify admin and choose Add custom pixel. Give it a name and make sure the correct data is sent to the tweakwiseLayer.
// 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', '{instancekey}', "//navigator-analytics.tweakwise.com/bundles/scout.js");
// subscribe to event
analytics.subscribe("checkout_completed", function (event) {
tweakwiseLayer.push({
event: 'purchase',
data: {
profileKey: profileKey,
productKeys: event.data.checkout.lineItems.map(o => o.merchandise.product.id),
revenue: event.data?.checkout?.totalPrice?.amount
}
});
});
Notes:
- the customer events are sandboxed, so the event tag needs to be loaded again.
- this is a pseudo implementation, actual checkout_completed event might need a slight change on the mapping side
Property | Value / description |
---|---|
profileKey | The profile key identifying the visitor. Accepted characters: letters (A-Z, a-z), numbers (0-9), and dashes (-) |
productKeys | Array of unique id's of the items in the transaction. These are itemid that are known at Tweakwise. Check the feed generation what value should be used here. |
revenue | The total revenue from the purchase, calculated as the sum of product prices after discounts have been applied and before taxes are added. Can be empty, or must contain a value greater than or equal to 0. |
Note: the productKeys should be the productid that is known to Tweakwise. Check the feed generation what value should be used here.