GTM implementatie - oude Enhanced Ecommerce datalayer

Wil je je events naar Squeezely via GTM sturen? Dan kan je op deze pagina voor elk standaardevent voorbeeldcode vinden. Onderstaande code is gebaseerd op een enhanced e-commerce datalayer, wanneer je datalayer een andere syntax heeft moet je de waardes van de variabelen wijzigen.

Variabelen


(type: Datalayer variable, versie 2)

DLV - products product page: ecommerce.detail.products
DLV - order: ecommerce.purchase.actionField
DLV - purchase products: ecommerce.purchase.products
DLV - purchase actionfield: ecommerce.purchase.actionField
DLV - category: ecommerce.impressions.0.category
DLV - products cart: ecommerce.add.products
DLV - remove cart products: ecommerce.remove.products

Alternatief kan je ook een “ecommerce” variabele aanmaken en per tag de relevante objecten aanspreken, bijvoorbeeld:
{{DLV - ecommerce}}.detail.products

Tags

Custom HTML tag, elk script moet tussen <script type="text/javascript"> en </script> staan. De trigger = event of relevante pageview.

Wil je extra velden toevoegen? Vul deze aan bij het data object voor je het verstuurt, bijvoorbeeld data.email = {{email adres}}.

Viewcontent

 

<script type="text/javascript"> var products = {{DLV - products product page}}; var sqProducts = []; var data = {}; data.event = "ViewContent"; for (var i = 0; i < products.length; i++) { sqProducts[i] = []; if (products[i].id != null) { sqProducts[i].id = products[i].id; } if (products[i].name != null) { sqProducts[i].name = products[i].name; } if (products[i].price != null) { sqProducts[i].price = products[i].price; } } data.products = sqProducts; window._sqzl = window._sqzl || []; window._sqzl.push(data); </script>


Viewcategory

 

<script type="text/javascript"> var data = {}; data.event = "ViewCategory"; if ({{DLV - category}} != null) { data.category_id = {{DLV - category}}; } window._sqzl = window._sqzl || []; window._sqzl.push(data); </script>


AddToCart

 

<script type="text/javascript"> var products = {{DLV - products cart}}; var sqProducts = []; var data = {}; data.event = "AddToCart"; for (var i = 0; i < products.length; i++) { sqProducts[i] = []; if (products[i].id != null) { sqProducts[i].id = products[i].id; } if (products[i].name != null) { sqProducts[i].name = products[i].name; } if (products[i].price != null) { sqProducts[i].price = products[i].price; } if (products[i].quantity != null) { sqProducts[i].quantity = products[i].quantity; } } data.products = sqProducts; window._sqzl = window._sqzl || []; window._sqzl.push(data); </script>

 

RemoveFromCart

 

<script type="text/javascript"> var products = {{DLV - remove cart products}}; var sqProducts = []; var data = {}; data.event = "RemoveFromCart"; for (var i = 0; i < products.length; i++) { sqProducts[i] = []; if (products[i].id != null) { sqProducts[i].id = products[i].id; } if (products[i].name != null) { sqProducts[i].name = products[i].name; } if (products[i].price != null) { sqProducts[i].price = products[i].price; } if (products[i].quantity != null) { sqProducts[i].quantity = products[i].quantity; } } data.products = sqProducts; window._sqzl = window._sqzl || []; window._sqzl.push(data); </script>

Purchase

 

<script type="text/javascript"> var products = {{DLV - purchase products}}; var order = {{DLV - purchase actionfield}}; var sqProducts = []; var data = {}; data.event = "Purchase"; if (order.id != null) { data.orderid = order.id; } if (order.revenue != null) { data.totalvalue = order.revenue; } for (var i = 0; i < products.length; i++) { sqProducts[i] = []; if (products[i].id != null) { sqProducts[i].id = products[i].id; } if (products[i].name != null) { sqProducts[i].name = products[i].name; } if (products[i].price != null) { sqProducts[i].price = products[i].price; } if (products[i].quantity != null) { sqProducts[i].quantity = products[i].quantity; } } data.products = sqProducts; window._sqzl = window._sqzl || []; window._sqzl.push(data); </script>