0
votes

I'm working with Enhanced Ecommerce at the moment; getting data from a site for Google Analytics but not everything is working.
The cart tracking (payment and shipping) is working and I can see this on Google Analytics, but Tracking Product Clicks, Measuring Views of Products, Tracking Additions to Cart, and Tracking Removals from Cart are not working as they should.

When I load certain parts of the pages, the Data Layer is not populated with any data using the following code:

    //Tracking Product Clicks
        dataLayer.push({
           "event":"EEproductClick",
           "ecommerce": {
             "currencyCode": curr,
             "click": {
               "actionField": {"list":"category" },
               "products": [{
                 "id": pdc,
                 "name": GarmName,
                 "price": prix,
                 "brand": "MyBrand",
                 "category": ""
              }]
            }
          }
        });
//End


//Measuring Views of Product Details
        dataLayer.push({
           "ecommerce": {
             "currencyCode":curr,
             "detail": {
               "actionField": {"list":""},     //optional list property
               "products": [{
                 "id":pdc,
                 "name":GarmName,
                 "price":prix,
//               "brand":"Boss",
//               "category":"Men/Clothing/T-Shirts",
//               "variant":"black"
              }]
            }
          }
        });
//End

//Tracking adds to cart
        dataLayer.push({
           "event":"EEaddToCart",
           "ecommerce": {
             "currencyCode": curr,
             "add": {
               "products": [{
                 "id": pdc,
                 "name": GarmName,
                 "price": prix,
                 "brand": "MyBrand",
//               "category":"Men/Clothing/T-Shirts",
//               "variant":"black", //optional, if there is a variant of the product
                 "quantity":1
              }]
            }
          }
        }); 
//End

//Tracking removes from cart
        dataLayer.push({
           "event":"EEremoveFromCart",
           "ecommerce": {
             "currencyCode": curr,
             "remove": {
               "products": [{
                 "id": pdc,
                 "name": GarmName,
                 "price": prix,
                 "brand": "MyBrand",
//               "category":"Men/Clothing/T-Shirts",
//               "variant":"black", //optional, if there is a variant of the product
//               "quantity":1
              }]
            }
          }
        }); 
//End

I'm currently using the following code which does populate the data layer, but using Google Tag Manager, no data is being sent to Google Analytics except the purchase process.

    //Measuring Views of Product Details
        dataLayer.push({
          event: 'ProductView',
          ecommerce: {
            detail: {
              actionField: {
                list: 'Search Results'
              },
              products: [{
                id: pdc,
                name: GarmName,
//              category: 'guides/google-tag-manager/enhanced-ecommerce',
//              variant: 'Text',
//              brand: 'SIMO AHAVA',
//              dimension3: 'Ecommerce',
//              metric5: 12,
//              metric6: 1002
              }]
            }
          }
        }); 
//END

//Measuring Product Clicks
        dataLayer.push({
        event: 'EE_ProductView',
        'ecommerce': {
        'detail': {
            'actionField': {},
                'products': [{
                    'name': GarmName,
                    'price': prix,
                    'id': pdc
                    }]
                }
            }
        })
//End

//Measuring Additions or Removals from a Shopping Cart
        dataLayer.push({
          'event': 'addToCart',
          'ecommerce': {
            'currencyCode': curr,
            'add': {
              'products': [{
                'name': GarmName,
                'id': pdc,
                'price': prix,
                'quantity': 1
               }]
            }
          }
        });
//End

// Measure the removal of a product from a shopping cart.
        dataLayer.push({
          'event': 'removeFromCart',
          'ecommerce': {
            'remove': {
              'products': [{
                  'name': GarmName,
                  'id': pdc,
                  'price': prix,
                  'quantity': 1
              }]
            }
          }
        });
//End

What am I doing wrong for one set of code to work and another to not? And how can I get GTM to push the data it is receiving to Google Analytics, please?

Many Thanks

EDIT: I've deleted my code and GTM/GA tags and rewritten them all and it seems to now be working to an extent. Still getting the same issues though so will look into this further

3

3 Answers

1
votes

Looking at you tag, your EE_ProductView trigger is set for PageView, which is firing before you are pushing data to your dataLayer. It depends when you are pushing items to the dataLayer as to which trigger you would want to use. You can probably use a Window Loaded trigger if you are pushing items to the dataLayer as part of the page load. For events that occur after page load (e.g., clicks), you can use a Custom Event trigger that fires on the event name (e.g., "EE_ProductView").

0
votes

Can you post a screenshot of your tag in GTM, do you have correct triggers on your tag, and do those triggers even happen on the website?

0
votes

I deleted all code and tags, and started from scratch. Changing some of the tags from 'event' to 'page view' and vice versa seems to have fixed the issue I was having.
Data is now being pushed to DataLayer and is picked up by GA.

Thanks to all for your help