Suppose you're using a non-standard Shopify website (Headless). In that case, it is possible that some of Rep's automatic event tracking will not work correctly because of the non-standard structure of the website.
You can use this guide to inject these snippets using Google Tag Manager or directly into the website's code.
Make sure to replace all the placeholders marked in bold with actual values by extracting these values from your website.
Page Viewed event:
Trigger on every page load
<script> event = 'PRODUCT_VIEWED';
properties = {
"product_id" : {product_id},
"name" : {product_name},
"url" : window.location.href
};
(function (w, l) { w[l] = w[l] || [];
var d = {
et: event,
d: properties };
w[l].push(d);
}) (window, 'vfAnalytics');
</script>
Product Viewed event:
Trigger on every page load of a PDP
<script> event = 'PRODUCT_VIEWED';
properties = {
"product_id" : {product_id},
"name" : {product_name},
"url" : window.location.href
};
(function (w, l) { w[l] = w[l] || [];
var d = {
et: event,
d: properties };
w[l].push(d);
}) (window, 'vfAnalytics');
</script>
Product List Viewed event:
Trigger on every page load of a collection page
<script> event = 'PRODUCT_LIST_VIEWED';
properties = {
"list_id" : {collection_id},
"query" : window.location.search.replace("?", ""),
"product_group" : {collection_name},
"url" : window.location.href
};
(function (w, l) { w[l] = w[l] || [];
var d = {
et: event,
d: properties };
w[l].push(d);
}) (window, 'vfAnalytics');
</script>
Product Added event:
Trigger after a product is added to the cart
<script> event = 'PRODUCT_ADDED';
properties = {
"product_id" : {product_id},
"name" : {product_name},
"variant" : {variant_id},
"price" : {variant price},
"quantity" : {quantity},
"url" : window.location.href
};
(function (w, l) { w[l] = w[l] || [];
var d = {
et: event,
d: properties };
w[l].push(d);
}) (window, 'vfAnalytics');
</script>