Search code examples
google-analyticse-commercedom-eventsgoogle-tag-managermeasurement-protocol

How to test and implement data layer in Google Tag Manager for Google Analytics


We are using enhanced eCommerce tracking by using data layer, to setup and test it in local environment. We can see page views in analytics but the event and impressions are not triggered. I tried using this:

dataLayer.push({ 
    'ecommerce': { 'Impression': [ { 'name': '${product.name}' ,'id': '${product.code}' }]}

});

dataLayer.push({
     'ecommerce': 
     { 'detail': 
        {    'products': 
                    [{ 
                        'name':  '${product.name}',  
                        'id': '${product.code}',
                        'variant': '${product.style}' 
                    }]
        } 
    } 
});

But I don't know how to test in local. I have tested using Google tag manager Debug mode, but it shows datalayer has been pushed but I can't track that event in Google Analytics


Solution

  • In localhost used to check tracking by Google Tag Assistant

    https://chrome.google.com/webstore/detail/tag-assistant-by-google/kejbdjndbnbjgmefkgdddjlbokphdefk

    I think it is best way to check datalayer