Skip to main content
All CollectionsTroubleshooting
Google Analytics Events missing Add To Cart event
Google Analytics Events missing Add To Cart event
Updated over a week ago

If you're using the official Shopify apps from Google or Meta, you should be receiving events as normal.

If you have your own Datalayer implementation, or are using other apps, adaptions might be needed.

We are firing a custom event:

eliteAddProductToCart

The event does not contain any parameters, because datalayers are often built in a datalayer.liquid file.

You could hence listen to our custom event and use it to trigger your datalayer actions.

E.g. here is a snippet from a hypothetical datalayer.liquid:

{% if template contains 'product' %}  
var ecommerce = {
'items': [{
'item_id' : {{product.id | json}},
'item_variant' : {{product.selected_variant.title | json}},
}]
};
var ecommerceadd = {
'items': [{
'item_id' : {{product.selected_variant.id | json}},
'item_variant' : {{product.selected_variant.title | json}},
}]
};
dataLayer.push({
'pageType' : 'Product',
'event' : 'ga_view_item',
ecommerce
});

/* HOW IT WORKED BEFORE - LISTENING TO A CLICK EVENT */
$(__DL__.cartTriggers).click(function(){
dataLayer.push({
'event' : 'ga_add_to_cart',
ecommerceadd
});
});

/* CODE TO ADD INSTEAD - LISTENING TO THE CUSTOM EVENT */
$(document).on('eliteAddProductToCart', function() {
dataLayer.push({
'event': 'ga_add_to_cart',
ecommerceadd
});
});

{% endif %}

Did this answer your question?