Ad

No Data In GA And GTM Using DataLayer

I'm using Google Tag Manager and dataLayer to pull information from an eCommerce site to Google Analytics, but for the past few days the 'Add to Cart' chart has been empty, even though the test site is working fine, pulling data as it should, and I've used the same code copied across.

I can see the trigger firing in preview mode, and in live events it appears as an add to cart event but no data is showing in shopping behavior which I cannot work out.

This is the code I'm using for dataLayer:

        dataLayer.push({
        'event': 'addToCart',
        'ecommerce': {
            'currencyCode': curr,
            'add': {                       
              'products': [{               
                'id': pg,
                'name': garmentName,
                'price': garm,
                'brand': 'MyStore',
        //        'category': 'Apparel',
        //        'position': 0,
                'quantity': 1
               }]
            }
          }
        });

curr, pg, garmentName, and garm are all JavaScript variables pulled from the PHP the site runs on.

A screenshot of the tag I'm using is available here

Ad

Answer

There was nothing wrong with my code or tag, I had closed the function which contains the dataLayer push too early

Ad
source: stackoverflow.com
Ad