I have piece of GTM code in which event is sometimes placed at the top of the object and sometimes at the bottom. Now the question is, is there any difference (like one sending data from previous event) and which is the right way to handle it?
dataLayer.push({
'event': 'addToCart',
'ecommerce': {
'add': {
'actionField': { 'list': 'Bestsellers' },
'products': [{
'name': 'Product 1',
'id': 1,
'position': 1,
'quantity': 1
}]
}
}
});
Or
dataLayer.push({
'ecommerce': {
'add': {
'actionField': { 'list': 'Bestsellers' },
'products': [{
'name': 'Product 1',
'id': 1,
'position': 1,
'quantity': 1
}]
}
},
'event': 'addToCart'
});
Note this is just an example. In case of adding products to the cart the event is always at the top of dataLayer, but in case of impression the event is always at the bottom (this part of code was based on a tutorial found on the internet in which events were placed there). On the first glance, the GA stats seem to register just fine. However in case of the GTM+GA combo it's sometimes difficult to find out if something works incorrectly (as opposed to finding out if it works at all), hence the question.