2

I'm using Google Tag Manager to track purchases on a Magento website. I've set up GTM through the Magento admin and every product related event is triggering fine (productDetails, addToCart, purchase etc...).

I'm however having an issue with the checkout process. The only product data included in the dataLayer is the product id, name, price and quantity. I would however like to have the category of the product be included as well, so that I can see directly in Analytics the products sold by category.

Is there a way to update the variables in the dataLayer for the checkout and purchase steps, and if so how? I've been scouring the web for hours but can't seem to find an answer...

2
  • which magento version?
    – Sohel Rana
    Oct 11, 2017 at 14:07
  • Magento ver. 2.1.7
    – Clo
    Oct 11, 2017 at 14:28

1 Answer 1

1

You should be able to identify dataLayers for sending additional data to Google including category information. Have a look at the following link which will give you complete list of data which can be sent to GA

https://developers.google.com/tag-manager/enhanced-ecommerce

If you are a developer you should be able to identify where other data has been passed to GA and can add other information as par your requirement.

For example to send category name, you can pull category information on category page using the following code snippet -:

$_category = Mage::getModel('catalog/layer')->getCurrentCategory();
$_categoryName = '';

if ($_category){
    $_categoryName = $_category->getName();
}

In the similar manner you can do this on product detail, add to cart and checkout pages.

If you are not a developer then I would highly recommend to use third party extension because it comes with full implementation and you don't need to sweat a lot. Here are the two extensions which I would highly recommend for M1 and M2.

Magento Google Tag Manager for Enhanced Ecommerce Tracking

Magento 2 Google Tag Manager for Enhanced Ecommerce Tracking

Hope it helps

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.