i’m currently trying to implement Google analytic events in magento 2 shop but since i’m relatively new to the concept, that’s why i have difficulties implementing it.
If someone already has experience in it, i’ll be very grateful, if i get some support.
Task description:
When the user clicks on the shipping information during checkout.
TODO: When clicking on the “Check & Pay” button on the shipping costs page, the following JS should be executed:
<script>
dataLayer.push({ ecommerce: null });
dataLayer.push({
event: "add_shipping_info",
ecommerce: {
currency: "EUR",
value: 33.33, // cart value (Subtotal / $cart->getQuote()->getSubtotal())
shipping_tier: "Standardversand", // selected shipping type
items: [ // All cart items
{
item_id: "SKU_12345",
item_name: "Stan and Friends Tee", // Attribute zshortname
price: 11.11,
quantity: 1
},
{
item_id: "SKU_54321",
item_name: "Stan and Friends Tee", // Attribute zshortname
price: 22.22,
quantity: 2
}
]
}
});
</script>