Filter Our Blog Posts by Google Marketing Platform Product:
Filter Our Blog Posts by Google Marketing Platform Product

Enhanced Ecommerce: Keys to Accurate Data

Anton Dolgiy   
January 17, 2018  
Main Image

Having clean ecommerce data in Google Analytics is both necessary and sufficient to a good ecommerce implementation. Only GA can give you a holistic view on how all ecommerce-related actions on the site are measured.

The Enhanced Ecommerce plug-in for Google Analytics provides visibility into the user’s online shopping experience and is invaluable for marketers seeking to optimize the process of making a purchase on their site. Having the ecommerce tracking set up correctly ensures that you will get actionable insights into whether your site’s customer experience is driving users to the desired action – purchase. On the other hand, multiple bugs and errors might prevent you from seeing the real picture. Implementing Enhanced Ecommerce is always a hurdle and this post was created to help avoid widespread pitfalls.

When development work of implementing Enhanced Ecommerce on your site is finished and you see all the data being pushed to the dataLayer correctly, check your Google Analytics profile and make sure that the data meets your expectations. If the data isn’t what you expect, you’ll need to dig deeper to discover what the cause is. It could be genuinely surprising insights, or it may be that your implementation of Enhanced Ecommerce is somehow flawed.

We are going to examine the most frequent cases of erroneous data and how to fix your Enhanced Ecommerce implementation when it goes wrong. For greatest clarity, we are going to focus on Google Tag Manager (GTM)-based analytics implementation where the dataLayer is actively used.

Case 1. HTTP Request Limit exceeded (aka Payload size is too large)

This error appears even if your ecommerce code is correct and only depends on the number of objects in an array that your site is trying to send to Google Analytics. It typically happens to product impressions or promotion impressions on a page when the number of them being sent concurrently is big enough.

The maximum number of objects when this error is triggered may vary from site to site and is a function of amount of data collected with product impressions: product name, id, price, brand, category, variant, list. Additionally, some other data can be collected within the same hit: custom dimensions and metrics, autoLink domains etc. As a rule, if the number of objects collected in a single hit is higher than 50 you’ll probably see the mentioned issue.

At first glance, we’ll lack only product or promo impressions in Google Analytics. In practice, the situation is different. First of all, according to Google’s recommendations, we don’t need to create another tag to collect Enhanced Ecommerce data – it’s enough to just enable Enhanced Ecommerce features in a regular pageview tag:

Since it’s a common practice to send product impressions with a pageview, the pageview itself won’t be sent to Google Analytics if we face the HTTP Request Limit issue. This means that a user temporarily disappears from the site – if no other hits are registered on the same page.

Once we’ve identified the issue and the importance of solving it, let’s proceed with a solution.

The essence of the solution is the following: we’ll need to split the array of product or promo impressions into several ones. Navigating your site could help you identify the number of objects that can be painlessly sent within a single hit.

If we can involve a developer to fix the issue it makes things easier: a developer can create a product impression array and to push it to the dataLayer by parts. But what if development resources are limited or the release is scheduled in a day or two?

Let’s say that our site has some product listings containing 70 objects. Simple observation helped us see that 35 products are being sent properly in a single HTTP request. Therefore, our solution is as simple as follows: to split the product array into two ones with 35 products in each.

Since your implementation is GTM-based and you have all the correct data in dataLayer, you can fix everything even without touching the source code. We’ve created a step by step guide that you can access here.

 Case 2. Combining Product Detail and Product Impression Data

Many ecommerce sites place related products on product detail pages. Everything that is named “You May Also Like”, “Buy with These”, “Frequently Bought Together”, or “Recently Viewed” products – should be measured in the Enhanced Ecommerce implementation as product impressions.

The Google documentation says that it is possible to combine product detail views and product impressions and to measure them in a single hit. It means that once the following code is pushed to the dataLayer the product detail and product impression data will be both sent to Google Analytics:

<script>

dataLayer.push ({'ecommerce': {

                              'impressions': [

     {

       'name': 'T-Shirt',       

       'id': '12345',

       'price': '10.00',

       'brand': 'Brand1',

       'category': 'Apparel',

       'variant': 'V-neck',

       'list': 'Buy with This',

       'position': 1

     },

     {

       'name': 'Jeans',

       'id': '67890',

       'price': '30.00',

       'brand': 'Brand2',

       'category': 'Apparel',

       'variant': 'Relaxed',

       'list': 'Buy with This',

       'position': 2

     }],

      'detail': {

      'actionField': {'list': 'Sales'},

      'products': [{

        'name': 'Jacket',      

        'id': '11111',

        'price': '40.00',

        'brand': 'Brand3',

        'category': 'Apparel',

        'variant': 'Black'

       }]

     }

                    }

});

</script>

If this scenario happens, both ec:addImpression and ec:addProduct (along with ec:setAction) commands are executed and all the data is being sent to Google Analytics:

In practice, product impressions and detail view data are rarely pushed together, i.e., within the same dataLayer.push(). Let’s say that product detail data is being pushed first and impression data – a moment later, in a different push() method. Therefore, you will see the following picture in the GTM debug pane:

Our Enhanced Ecommerce tag is firing on the Window Loaded event when all the data has been already pushed to the dataLayer. But once we check the JavaScript console we’ll see a weird thing: only ec:addImpression command is executed and therefore, only impression data of related products is being sent to Google Analytics:

Why is this happening? We have pushed product detail view data as well as impression data to the dataLayer, and the syntax is correct. The point is that Google Tag Manager can access the latter ‘ecommerce’ object only if we select the ‘Use Data Layer’ option in our ecommerce tag set up. This would result in losing product detail or impression data depending on which dataLayer.push() is done earlier.

Let’s proceed with solutions now. Depending on your resources and the content on your product detail pages, you have a few options for solving the issue:

  1. Add everything in a single push

If you can involve your development team, you need to ask them to combine detail view and product impression data in a single dataLayer.push(). All the data being added within one push() will be sent to Google Analytics as a result of execution of the ec:addImpression and ec:addProduct commands.

Even if you need to measure two or more sets of impressions on the same page (“Recently Viewed” and “Frequently Bought Together”) alongside with product detail views, this method would work.

  1. Add an event to every push

You can ask your developer to add the event key to every dataLayer.push() when impression or product detail data is added:

<script>

dataLayer.push ({'ecommerce': {                        

    'detail': {

      'actionField': {'list': 'Sales'},

      'products': [{

        'name': 'Jacket',      

        'id': '11111',

        'price': '40.00',

        'brand': 'Brand1',

        'category': 'Apparel',

        'variant': 'Black'

       }]

     }

                   },

                 'event': "GAecommerce"

});

</script>

Then, just add ‘GAecommerce” as a custom event to fire your Enhanced Ecommerce tag which will have the Use Data Layer option enabled. The tag will fire several times and each piece of ecommerce data will be sent separately.

You will just need to make sure that you are sending ecommerce data with a tag of the Event type and thus, not increasing the number of pageviews.

This method also works if you need to send two (or more) different impression objects. Once two different sets of product impressions are added to the dataLayer in separate pushes, e.g. “Recently Viewed and Frequently Bought Together”) the latest object with the impressions action will overwrite (completely or partially) the previous impression object.

If the event key is added the latest impression object will not prevent the previous one from being sent to GA.

  1. Use the Read Data from Variable option

This is the most preferred option if you don’t want to involve a developer or touch the code. The solution is as simple as to access impression and detail objects on a product detail page and to combine these in a single JavaScript variable:

function () {

  var ecom = {'ecommerce' : {

    'impressions': {{impressions}},

    'detail': {{detail}}

  }

};

  return ecom;

}

The {{impressions}} and the {{detail}} variables are the dataLayer variables pulled from the ecommerce object:

Then, modify your Enhanced Ecommerce tag settings from “Use Data Layer” to “Read Data from Variable” and reference the above JavaScript variable as a source for the ecommerce data. Note that if your regular Enhanced Ecommerce tag uses the dataLayer to access the data you should create another tag for product detail pages and to add them as an exception to the main tag.

This method wouldn’t work for several impression objects since the latest one will still overwrite the previous object (or objects). So, if you have different impression sets on a page, e.g. ‘Recently Viewed’ and ‘Frequently Bought Together’ you will need to use the first or the second method instead.

Case 3. Product-scoped custom dimensions

Product-scoped custom dimensions and metrics are unique in their set up. You will need to keep in mind a couple of things about this kind of custom variables.

Firstly, they work for Enhanced Ecommerce only and won’t be read by GTM with Standard Ecommerce implementation. The following custom dimension used to state the in-stock status for clothing (“Yes”
or “No”) will never get sent to GA:

<script>

dataLayer.push({

     'transactionId': '123456789'

     'transactionTotal': 500.00, 

     'transactionTax': 10.00,                                                 

     'transactionProducts': [{

        'sku': '00001',                                                                        

        'name': 'T-Shirt',                                                      

        'category': 'Apparel',                                                    

        'price': 490.00,                                                                       

        'quantity': 1,

        ‘dimension1’: 'Yes'                                                                          

}]   

    });

</script>

Secondly, product-scoped custom dimensions and metrics don’t require additional customization in GTM. Thus, if you want to set up hit-, session- or user-level custom dimensions in GTM you will need to:

  1. If this is a dataLayer variable it should be implemented in the dataLayer first;
  2. Add a new custom dimension / metric in your Google Analytics profile;
  3. Create a variable in GTM – this can be a dataLayer variable, part of a URL, custom JavaScript and variables of other types;
  4. Add an index of the added custom dimension / metric from GA and value of the variable created at step 2 to your GTM tag – pageview, transaction or event tag.

However, you don’t have to pick a value of product-scoped dimensions and metrics from dataLayer. So, there are two main steps of setting up a product-level custom dimension or metric:

  1. Add a new custom dimension / metric in your Google Analytics profile, select Product as a scope;
  2. Implement a custom dimension / metric in the dataLayer adding it into a products array object (Enhanced Ecommerce) with an index from the 1st step, e.g. ‘dimension1’ or ‘metric1’;

That’s it – once you enable the Enhanced Ecommerce features in your tag and select Use Data Layer this custom dimension or metric will be sent to GA:

<script>

dataLayer.push ({'ecommerce': {

                              'purchase': {

                                   'actionField': {

                                      'id': '123456',                         

                                      'revenue': '50.00',                              

                                      'tax':'5.00',                                           

                                      'shipping': '5.00'                                  

                             },

                             'products': [{

                                 'name': 'T-Shirt',       

                                 'id': '12345',

                                'price': '10.00',

                                'brand': 'Brand1',

                                'category': 'Apparel',

                                'variant': 'V-neck',

                                'quantity': 1,

                                'dimension1': 'Yes'

                             },{

                                     'name': 'Jeans',

                                     'id': '67890',

                                     'price': '30.00',

                                    'brand': 'Brand2',

                                    'category': 'Apparel',

                                    'variant': 'Relaxed',                                         

                                    'quantity': 1,

                                    'dimension1': 'No'                              

                                   }]

                        }

                    }

});

</script>

Case 4. Inconsistent product list taxonomy and product list attribution

If your product list names are complex, you need to make sure they have consistent spelling throughout the entire purchase funnel. You might be specifying product categories, subcategories, subcategories of the 2nd level, etc. in a product list name.

For instance, if your product list is named Clothing/Men’s/T-Shirts/Featured and you have a few spelling variations in your Enhanced Ecommerce implementation:

  1. Clothing/Men’s/T-Shirts/Featured
  2. Clothing/Men’s/T-shirts/Featured
  3. Clothing/Mens/T-shirts/Featured

Let’s say that the first version is used in the impression array, the second one was implemented for product clicks, and the third version is included as an optional list property in the detail action object. This means that this list name will appear as three different rows in the Product List Performance ecommerce report:

As we can see, product list views (i.e., impressions) were attributed to the first variation of the list name, product list clicks (i.e., product clicks) were attributed to the second one, and the third version of list spelling took credit for additions to cart, product checkouts and purchases.

Interesting note: if you added the third variation to product detail views only (as an optional list key) the same list name will take credit for any add-to-cart actions, product checkouts, or even purchases. This is happening because the list attribute persists for all the subsequent Enhanced Ecommerce actions within the same session. The last list name will be attributed to all the ecommerce actions taken by a user afterwards. It’s quite similar to the Last Non-Direct Click attribution model, isn’t it?

Case 5. Products are not displayed on a page

The last recommendation is obvious but nevertheless might be useful. If some products become visible on a page only on clicking a button, or tab, or checking a check-box, or selecting a filter, they shouldn’t be pushed to the dataLayer as product impressions on a page load.

Unless products are explicitly displayed on a page, no impression data should be pushed. It makes absolute sense because a user can’t view or interact with products on a site until they are shown.

That means, if a user should click the Frequently Bought Together button to view products, make sure that product impressions are pushed with an event not earlier than the button is clicked:

<script>

dataLayer.push ({'ecommerce': {

                              'impressions': [

     {

       'name': 'T-Shirt',       

       'id': '12345',

       'price': '10.00',

       'brand': 'Brand1',

       'category': 'Apparel',

       'variant': 'V-neck',

       'list': 'Frequently Bought Together',

       'position': 1

     }],

                    },

      ‘event’: ‘GAecommerce’

});

</script>

Now that the impression data becomes available, grab it with an event tracking tag having the Enable Enhanced Ecommerce features enabled. Fire this tag with a custom event trigger (the GAecommerce custom event).

Hopefully, our Enhanced Ecommerce recommendations will help make your data meaningful and actionable.

If you know different ways to improve Enhanced Ecommerce implementations, please share them with us!

 


Ready to take your ads to the next level?  
DELVE is your strategic partner for site-side analytics, campaign management, and advanced marketing science. As experts in the Google Analytics 360 Suite, DoubleClick Digital Marketing Solutions, and Google Cloud Platform, DELVE drives client growth through a data-driven mindset that converts digital inefficiency into hard ROI.
SEE EXAMPLES of our experience and reviews from our clients.
Contact us to learn more about how we help our clients get advertising right.