Somebody Killed My dataLayer – 4 Common Mistakes When Implementing eCommerce Tracking Using The dataLayer

Google Tag Manager can make adding and removing tags from your website an absolute breeze, however, get it wrong and it can be an absolute headache. Here are 4 mistakes we see all the time and how to avoid them…

We’re big fans of Google Tag Manager (GTM for those in a rush). Over the past 12 months or so we’ve helped countless clients get up and running with Tag Manager and have encountered lots of pitfalls that often stop things from working as expected. The biggest area of difficulty we hit is always setting up eCommerce tracking. This crucial (but often tricky) component of web analytics is pivotal to so many businesses, giving people full visibility of what they’re selling online.

Here’s a quick summary of simple mistakes that have really sent things crashing to earth with a bang – or at least stopped the eCommerce data populating in Google Analytics properly.

Including Currency Symbol

When sending the product price to the dataLayer don’t include the currency symbol. Doing so will simply mean your sale doesn’t track.

Correct:

'revenue': '35.43',    

Incorrect:

'revenue': '$35.43',    

Not Telling The dataLayer That It’s a Purchase

We’ve seen a few instances where the purchase component of the dataLayer push event is not included. Check out the example below:

Correct:

dataLayer.push({
  'ecommerce': {
    'purchase': {
      'actionField': {
        'id': 'T12345',                         // Transaction ID. Required for purchases and refunds.
        'affiliation': 'Online Store',
        'revenue': '35.43',                     // Total transaction value (incl. tax and shipping)
        'tax':'4.90',
        'shipping': '5.99',
        'coupon': 'SUMMER_SALE'
      },

Incorrect:

dataLayer.push({
  'ecommerce': {
        'actionField': {
        'id': 'T12345',                         // Transaction ID. Required for purchases and refunds.
        'affiliation': 'Online Store',
        'revenue': '35.43',                     // Total transaction value (incl. tax and shipping)
        'tax':'4.90',
        'shipping': '5.99',
        'coupon': 'SUMMER_SALE'
      },

Using Enhanced eCommerce code When Not Enabled and Vice Versa

If you’re using enhanced eCommerce tracking code, make sure you’ve enabled it in Google Analytics, if you haven’t deployed the correct enhanced eCommerce code on your site (i.e. you’re using the older version of eCommerce tracking) then make sure you keep it disabled in Google Analytics otherwise you’ll end up with missing data.  Missing product category data is the most common one that we come across.

How to enable (and disable) enhanced eCommerce tracking:

Enable Enhanced eCommerce

Not Defining a dataLayer Before Using eCommerce ‘push’ Events

If you’re including dataLayer.push events in your page code but are not seeing the data pull into your dataLayer using GTM’s preview mode then it’s likely that you still need to define a dataLayer in the head of your page, making sure it’s above the GTM code.

Here’s what an empty dataLayer looks like:

<script>
  dataLayer = [];
</script>

Remember, in the event of your GTM or Google Analytics not working as expected, remain calm at all times then call a Digital Ninja.