In this article, I will explain the product data import feature of Google Analytics. I will do that by showing, how the product data import feature can be used to correctly install the enhanced ecommerce tracking on a website.

This article is especially useful for those optimizers who have either not installed enhanced ecommerce tracking yet or who have installed enhanced ecommerce tracking but they are not getting all of the enhanced ecommerce data in their reports.

You can install enhanced ecommerce tracking with and without Google Tag Manager (GTM).

I have written this article under the assumption that you are either going to install enhanced ecommerce tracking via GTM or you have already installed enhanced ecommerce tracking via GTM.

However, my article is equally valid even if you have installed enhanced ecommerce tracking without GTM or planning to install enhanced ecommerce without GTM.

Enhanced ecommerce tracking is one of the most difficult trackings to implement in Google Analytics. The bigger the ecommerce website, the more difficult implementing this tracking becomes.

The major part of enhanced ecommerce tracking set up is tagging the web pages and page elements (like ‘Add to Cart’ button) with product data. In the case of Google Tag Manager, we do the tagging via data layers.

Following is the example of a data layer for sending product impression data to Google Analytics:

<script>

// Product impressions are sent by pushing an impressions object

// containing one or more impressionFieldObjects.

dataLayer.push({

‘ecommerce’: {

‘currencyCode’: ‘USD’, // Local currency is optional.

‘impressions’: [

{

‘name’: ‘Deep U Neck Loose T-shirt’, // Name or ID is required.

‘id’: ‘5678698’,

‘price’: ‘36.50’,

‘brand’: ‘VB’,

‘category’: ‘New Clothing’,

‘variant’: ‘White’,

‘list’: ‘Search Results’,

‘position’: 1

},

{

‘name’: ‘Hooded Pointed-Long-Hem Cowl Top’,

‘id’: ‘8879609’,

‘price’: ‘67.65’,

‘brand’: ‘VB’,

‘category’: ‘New Clothing’,

‘variant’: ‘Black’,

‘list’: ‘Search Results’,

‘position’: 2

}] }

});

</script>

As you can see, the data layer lists the product information of two products listed on a search result page.

But what if your search result page list 10 products or 100 products? In that case, your data layer would contain product information for 10 or 100 products.

This will make your data layer extremely large and here is where the problem occurs.

Google Analytics has put a limit on the amount of data you can send in a hit.

So when you send product data for dozens or hundreds of products (listed on a search result page or category page) via data layer to Google Analytics, then the size of the total data sent in a single hit may exceed the limit imposed by GA. In that case, there is no guarantee that all of the product data will be sent to GA.

This issue can create data discrepancies in your enhanced ecommerce reports. Consequently, you may not get all of the sales data or product data in your reports even when the data layers are all correctly installed and all GTM tags are correctly configured.

This is something that Google Analytics fails to mention in its help documentation. But this is something which you need to consider before creating and adding data layers to various pages of your website.

If your enhanced ecommerce reports are not showing all of the product or sales data and you can’t figure out what went wrong with the implementation, then exceeding the hit size limit could be the reason.

In order to minimize/eliminate the possibility of data loss, you need to minimize the amount of product data you send in a single hit. Product name, product price, brand, color, variant, etc are examples of product data.

We send this product data with each data layer which not only increases the size of the data layer but also increases the size of the data sent in a hit.

So if we don’t add this product data in a data layer, then this will reduce the size of the data layer and less amount of product data will be sent in a hit.

We can achieve this objective by importing all of the product data via the Google Analytics user interface or via the management API. In this way, we don’t need to send all of the product data with each enhanced ecommerce data layer.

We would then just need to send the product ID and any additional data (like list name and position) which was not imported.

Google Analytics will then automatically add all of the product data to the enhanced ecommerce hit at collection time by matching the product ID you sent in a hit to the corresponding product ID in the imported product data set.

For example, the following data layer….

<script>

// Product impressions are sent by pushing an impressions object

// containing one or more impressionFieldObjects.

dataLayer.push({

‘ecommerce’: {

‘currencyCode’: ‘USD’, // Local currency is optional.

‘impressions’: [

{

‘name’: ‘Deep U Neck Loose T-shirt’, // Name or ID is required.

‘id’: ‘5678698’,

‘price’: ‘36.50’,

‘brand’: ‘VB’,

‘category’: ‘New Clothing’,

‘variant’: ‘White’,

‘list’: ‘Search Results’,

‘position’: 1

},

{

‘name’: ‘Hooded Pointed-Long-Hem Cowl Top’,

‘id’: ‘8879609’,

‘price’: ‘67.65’,

‘brand’: ‘VB’,

‘category’: ‘New Clothing’,

‘variant’: ‘Black’,

‘list’: ‘Search Results’,

‘position’: 2

}] }

});

</script>

…could be trimmed down like the one below after product data import:

<script>

// Product impressions are sent by pushing an impressions object

// containing one or more impressionFieldObjects. // The product name, price, and other product data will be added to this hit

// at collection time if the value of the id field matches a Product SKU/ID you have uploaded. dataLayer.push({

‘ecommerce’: {

‘currencyCode’: ‘USD’, // Local currency is optional.

‘impressions’: [

{

‘id’: ‘5678698’,

‘list’: ‘Search Results’,

‘position’: 1

},

{

‘id’: ‘8879609’,

‘list’: ‘Search Results’,

‘position’: 2

}]

}

});

</script>

Even though you are now just sending product ID via data layer, your enhanced ecommerce reports would still be populated with all of the product data (product price, product brand, variant, color, size, etc).

New roadmap for enhanced ecommerce tracking set up via GTM

Following would be the process to implement enhanced ecommerce tracking via GTM once you have made Product data import a part of your setup:

#1 Determine your tracking requirements

#2 Decide the product data you want to import

#3 Create custom dimensions (optional)

#4 Create a product data set

#5 Upload Product data

#6 Create / Modify Data Layers

#7 Add data layers to predetermined web pages and pages elements.

#8 Create and configure your GTM tags.

#9 Test enhanced ecommerce tracking on the website.

#10 Remove existing ecommerce tracking code and deploy the new enhanced ecommerce tracking on your website.

Here the steps highlighted in bold (steps 2 to 6) are the new steps you need to follow while implementing/modifying an enhanced ecommerce tracking set up.

I am going to explain only the steps from 2 to 6 as they are new.

If you want to learn more about the other steps, then read this article: Implementing Enhanced Ecommerce Tracking via Google Tag Manager

#2 Decide the product data you want to import

The product data you want to import depends upon the product attributes available.

Following are the examples of product attributes:

Product name

Product price

Product brand

Product color

Product size

Product availability

#3 Create custom dimensions (optional)

If you have got product attributes (like product color and product size) which can’t be measured via any predefined dimension (i.e. the dimensions which are already available in GA) then you need to create new custom dimensions:

Here I have created two new custom dimensions called ‘Product Color’ and ‘Product Size’ to collect data related to product color and size.

Make sure that the custom dimensions you create to collect data for your product attributes must have the scope set to ‘Product’.

If the custom dimension scope is set to hit, session or user, then it won’t be available for upload as product data.

#4 Create a product data set

Follow the steps below to create a product data set:

Step-1: Navigate to the Admin section of your GA view and then click on the link ‘Data Import’ under ‘Property’ column:

Step-2: Click on the ‘Create’ button:

Note: Google Analytics’ terms of service do not allow you to upload personally identifiable information (like name, email address, house address, IP addresses, etc) via the data import feature.

Step-3: Select ‘Product Data’ as data set type:

Step-4: Click on the ‘Continue’ button.

Step-5: Enter the name of the new data set and then select the view(s) from the drop-down menu that will make use of the data in the data set:

Step-6: Click on the ‘Continue’ button and then define your data set schema like the one below:

Step-7: Set ‘Overwrite Hit data’ setting to ‘Yes’ and then click on the ‘save’ button:

Step-8: Click on the ‘Done’ button:

Step-9: Click on the ‘Get Schema’ button:

Step-10: Click on the ‘Download Schema template’ button and then click on the ‘Done’ button:

Step-11: The schema template is in the form of a CSV file. Open this file and then add all of the product data to this file:

ga:productSku => Product ID

ga:productName => Product name

ga:productBrand => Product Brand

ga:productCategoryHierarchy => Product Category

ga:productVariant => Product Variant

ga:productPrice => Product price

Step-12: Upload the CSV file you created to Google Analytics. There are two methods to upload this data. You can either upload the product data manually via the GA user interface or via management API.

I am going to show you how to upload the data via the user interface as it is an easier method.

Step-13: Click on the ‘Upload file’ button and then click on the ‘Choose File’ button to select your CSV file:

Step-14: Click on the ‘Upload’ button to upload product data to your GA property.

If the data is successfully uploaded then you would see the message ‘completed’ under the ‘Status’ column:

#6 Create / Modify Data Layers

Create trimmed down versions of enhanced ecommerce data layers as mentioned above.

Instead of passing all of the product information, just pass product IDs and any additional data (like list name, position, product coupon, etc) which wasn’t imported via Data import.

Other methods to reduce the size of enhanced ecommerce data layers

If you find your data layers too big even after using the product data import then there are three things you can do:

#1 Reduce the number of products you display at a time on product category pages, product sub-category pages or search result pages. This can be done by making changes to the website navigation.

#2 Push the product data of only those products into data layers that are actually viewed. One method of doing this is through scroll-based impression tracking which is explained in great detail in this article.

#3 Push only that data into data layers which are really important for your analysis.

There are ‘N’ things that can be tracked. But sometimes because of the shopping cart or CMS constraints or hit size limit it is not possible to track and send all of the data. In that case, we have to be very selective about the data we choose to send in a hit.