If you also use E-goi's Track & Engage to curb abandoned carts, this is how you integrate it with Google Tag Manager:
1) First and foremost, enable Track & Engage in your E-goi account and copy the HTML code we provide.
2) Login to Google Tag Manager, create a custom HTML tag, paste the HTML snippet you copied from Track & Engage and save the tag.
Done, you're all set! You can now add extra tags for whatever you need Track & Engage to do, such as dealing with abandoned carts.
Recovering abandoned carts
1) Be sure you've previously set up a tag which kickstarts Track & Engage (by following the steps above). Any other Track & Engage tag you add must always run after this initial tag.2) Go to Google Tag Manager and create the following data layer variables:
- PRODUCTS (the items your visitor added to cart)
- TOTAL_PRODUCTS (number of items in the cart)
- TOTAL_CART (amount to pay)
- ID_ORDER (purchase ID)
Use the code snippet below (make sure to replace our placeholder values with actual data parsed off your site):
<script>
dataLayer = [{
'TOTAL_PRODUCTS': 3,
'TOTAL_CART': '30',
'ID_ORDER': 'ABCDE12345',
'PRODUCTS': [
{sku:'123ABC',nome_produto: 'product1',categoria:'categoryA', preco:10, qtd:1},
{sku:'1234ABC',nome_produto: 'product2', categoria:'categoryB', preco:10, qtd:1},
{sku:'1235ABC',nome_produto: 'product3', categoria:'categoryC', preco:10, qtd:1}
]
}];
</script>
3) Then create a custom HTML tag for visitors adding items to their cart. Paste this into it and save it:
<script>
var valor = {{TOTAL_PRODUCTS}};
for(var i = 0; i < valor; i++)
{
_egoiaq.push(['addEcommerceItem',dataLayer[0].PRODUCTS[i].sku, dataLayer[0].PRODUCTS[i].nome_produto, dataLayer[0].PRODUCTS[i].categoria, dataLayer[0].PRODUCTS[i].preco, dataLayer[0].PRODUCTS[i].qtd]);
}
_egoiaq.push(['trackEcommerceCartUpdate',{{TOTAL_CART}}]);
</script>
4) Now let's create another custom HTML tag for anyone confirming their purchase. Paste this into it and save it:
<script>
_egoiaq.push(['trackEcommerceOrder',
"{{ID_ORDER}}", // (required) Unique Order ID
{{TOTAL_CART}}, // (required) Order Revenue grand total (includes tax, shipping, and subtracted discount)
</script>
And there you have it! These tags will allow Track & Engage to learn whether visitors left anything in their shopping carts, so you can then automate recovery campaigns in E-goi.
I haven't got a clue about how to do this in Google Tag Manager. Please help!
Don't worry, we'll sort you out :) Just message us using the "Help" menu.