0
votes

I've implemented enhanced ecommerce tracking in Google UA by populating the dataLayer with as far as I can see the correct data.

Here is the html of the actual datalayer script:

<script type="text/javascript">

    dataLayer.push({
        'ecommerce': {
            'purchase': {
                'actionField': {
                    'id': 'ZW10317808',                         // Transaction ID. Required for purchases and refunds.
                    'affiliation': 'Online Store',
                    'revenue': '9.95',                     // Total transaction value (incl. tax and shipping)
                    'tax':'0.00',
                    'shipping': '0.00',
                    'coupon': '',
                    'products': [

                        {
                            'name': 'Test product', // Name or ID is required.
                            'id': 'ZCMNR010',
                            'price': '9.95',
                            'brand': 'Brand',
                            'category': '',
                            'variant': '',
                            'quantity': 1
                            //, 'coupon': '' // Optional fields may be omitted or set to empty string.
                            } 
                    ]
                }
            }
        }
    });
</script>

And here is a sample output from the console so it appears (to me) that the values are all making to the dataLayer:

dataLayer
[
   0: {
      [functions]: ,
      __proto__: { },
      ecommerce: {
         [functions]: ,
         __proto__: { },
         purchase: {
            [functions]: ,
            __proto__: { },
            actionField: {
               [functions]: ,
               __proto__: { },
               action: "purchase",
               affiliation: "Online Store",
               coupon: "",
               id: "ZW10317808",
               products: [
                  0: {
                     [functions]: ,
                     __proto__: { },
                     brand: "Brand",
                     category: "",
                     id: "ZCMNR010",
                     name: "Test Product",
                     price: "9.95",
                     quantity: 1,
                     variant: ""
                  },
                  length: 1
               ],
               revenue: "9.95",
               shipping: "0.00",
               tax: "0.00"
            }
         }
      }
   },
   1: {
      [functions]: ,
      __proto__: { },
      event: "gtm.js",
      gtm.start: 1408351886007
   },
   2: {
      [functions]: ,
      __proto__: { },
      ecommerce: {
         [functions]: ,
         __proto__: { },
         checkout: {
            [functions]: ,
            __proto__: { },
            actionField: {
               [functions]: ,
               __proto__: { },
               step: "Order Confirmation"
            }
         }
      },
      event: "checkout"
   },
   3: {
      [functions]: ,
      __proto__: {
         [functions]: ,
         __proto__: null
      },
      event: "gtm.dom"
   },
   4: { },
   length: 5
]

The transaction is listed in UA but with 0.00 revenue, 0 items, etc. This transaction was from last week so unlikely to be data latency.

Also the checkout step tracking isnt showing in the reports either. I've enabled the enhanced tracking in the GA view and deployed the plugin view the setting in GTM.

I'm scratching my head. Hopefully a fresh pair of eyes can spot something obvious.

Thanks if you can help.

Thanks

1
I don't see anything obvious with your code. Have you tried using the Google Analytics Debugger to monitor the request? - Blexy
Blexy, many thanks for taking some time to look at this for me. I can confirm that I have resolved this issue and like often it was a simple defect that was hidden by my own eyes seeing what they wanted to and not what was there. My rendered script had a missing { from the code <pre> , 'products': [</pre> and the matching closing tag but otherwise appeared correct. Methodical debugging revealed the issue, which should have been my first port of call. And thanks for the Chrome extension, I was not aware of that and am installing it now. Every cloud.. :) - The Reluctant Coder

1 Answers

0
votes

Products must sit beneath "purchase", not within the actionFieldObject:

<script type="text/javascript">

dataLayer.push({
    'event': 'transaction',
    'ecommerce': {
        'purchase': {
            'actionField': {
                'id': 'ZW10317808',                         // Transaction ID. Required for purchases and refunds.
                'affiliation': 'Online Store',
                'revenue': '9.95',                     // Total transaction value (incl. tax and shipping)
                'tax':'0.00',
                'shipping': '0.00',
                'coupon': ''
            },
            'products': [

                {
                    'name': 'Test product', // Name or ID is required.
                    'id': 'ZCMNR010',
                    'price': '9.95',
                    'brand': 'Brand',
                    'category': '',
                    'variant': '',
                    'quantity': 1
                    //, 'coupon': '' // Optional fields may be omitted or set to empty string.
                    } 
            ]
        }
    }
});

Hope that helps.