Google Analytics Enhanced Ecommerce provides insight into Ecommerce performance in detail that was impossible using standard Google Analytics methods. To get the most out of Enhanced Ecommerce, you must understand the breadth of Enhanced Ecommerce data collection capabilities. This tutorial will take you from Ecommerce product page to Enhanced Ecommerce Product Data.
Product Data Problem and Solution
The new product schema was created to provide insight in a way that answers questions that are specific to products rather than pages or events. Consider event hits; their schema uses a sentence-like structure to describe an action. This does not map well to a product entity that is not bound by specific instances in time. The product schema is more similar to pageview hits that collect attributes of a page entity over time. But still, the data is collected on the page is in a different fashion.
For more, see Carmen Mardiros’ great conceptual explanation of Enhanced Ecommerce Data Layer and my slides on Enhanced Ecommerce schema.
Google Analytics Enhanced Ecommerce assigns a collection of properties to each product. At least one property is mandatory (either name or id), and other properties are optional: brand, category (up to five tiers), variant, price, quantity, coupon, and position. These properties describe either an attribute of the product or the context of the product action. These standard features provide a holistic understanding of how users interact with products in an Ecommerce store. But they don’t give the whole picture of how customers interact with products within the context of any particular business.
Understand how users interact with products based on qualitative dimensions like its availability, backorder date, release date or physical dimensions or appearance.
For instance, you may want to understand how your customers’ shopping behavior changes for products based on qualitative dimensions like its availability, backorder date, release date or physical dimensions or appearance. Likewise, there is more to understand about products’ quantitative information such as the cost of goods sold, previous price, discount, or profit. This is where custom dimensions and metrics come in.
Product Data Collection
Google Analytics collects data about product entities in a way that appropriately fits the concept of a product; each product is represented by Javascript Object. An Object is simply a thing represented by a collection of properties about that thing. In other words, a product entity would be represented by an Object that has a name property of “Clapper Light Switch” and a price property with a value of 30.00.
To extend the ability for an Object to describe a product entity, we can specify additional properties like “cost of goods sold,” or “backorder date.” At the code level, this means adding one more property “key”:”value” pair to the product entity object. The only difference is that the properties name will be a placeholder such as “dimension9” or “metric4.” The dimension or metric name will be assigned later within the Google Analytics interface. In Universal Analytics it would look like this:
ga("create", "UA-XXXXX-Y");
ga("require", "ec");
ga("ec:addProduct", {
"id": "81301",
"name": "Xantech AC1 Controlled AC Outlet",
"price": "78.55",
"brand": "Xantech",
"category": "AC1 Controlled AC Outlet",
"variant": "white",
"dimension3": "In stock - Ships Today", // stock status custom dim.
"metric2": 5, // rating stars custom metric
"quantity": 1 });
ga("ec:setAction", "add");
ga("send", "event", "Product", "Add to Cart", "Xantech AC1 Controlled AC Outlet");
and using the Google Tag Manager data layer, it would look like this:
dataLayer.push({
"event": "addToCart",
"ecommerce": {
"currencyCode": "USD",
"add": {
"products": [{
"id": "81301",
"name": "Xantech AC1 Controlled AC Outlet",
"price": "78.55", "brand": "Xantech",
"category": "AC1 Controlled AC Outlet",
"variant": "white",
"dimension3": "In stock - Ships Today", // stock status
"metric2": 5, // review stars
"quantity": 1
}]
}
}
});
For a great working example of this, see: https://ga-dev-tools.appspot.com/enhanced-ecommerce/
Setting Custom Dimension & Metric Names
The first thing to note is, if you are using the Google Tag Manager data layer to collect product data, make sure you have checked the “Enable Enhanced Ecommerce Features” and “Use data layer” boxes shown below. No matter if you are using the data layer or standard Universal Analytics collection code, you will have to do two things:
- Ecommerce and Enhanced Ecommerce Reports must be enabled. Just go into your Admin section > choose a View > Ecommerce Settings and toggle Enable Enhanced Ecommerce Reporting to “ON.”
- Custom Dimension and Metric must be activated, named, and configured as you want them to appear in Google Analytics reports. This is also done within the Admin interface. Go to Admin > choose a Property > Custom Definitions and click Custom Dimensions or Custom Metrics. Set the name, the scope to “Product”, and the state to “On.” For Custom Metrics, set the appropriate formatting type.
Note that these hits must be set at the product hit level. Otherwise, the data will not be collected as expected, if at all.
Enhanced Ecommerce Product Data Reports
Now you are ready to appreciate all your shiny new insights. To find these reports within the Reporting interface go to Conversions > Ecommerce > select a Product or Sales report.
From there you can see all your products and sort, filter, and view them by any their newly recorded properties. Metrics can also be added to Custom Reports to provide aggregate insights.
Inspecting, Debugging and Perfecting Product Data Collection
You may see something funny in your reports at this point or nothing at all. In my experience, Enhanced Ecommerce data is published as soon as the hit it was sent with is recorded. This is usually relatively quick. (Under 10 minutes) If something looks amiss, don’t worry. There are usually a few simple fixes that can be made to make sure the data is being collected and reported correctly. Assuming you have done everything correctly up to this point, there may be a few things you need to check and fix. Here’s a list:
- Inspect everything using the Google Analytics Debugger Chrome Extension. Download the Chrome Extension or Tag Assistant.
- Make sure the hit is being sent to the right property.
- Use mandatory product fields (name or id) as report dimensions. This is helpful when starting out. If you are looking at a report with a primary dimension of Product List, but are not yet collecting product list data, the report will appear to be empty.
- Make sure Ecommerce data is sent with a standard Google Analytics Hit. Enhanced Ecommerce data is buffered on the page until a stand Google Analytics hit is sent. Then the Ecommerce data is collected with that hit.
- Make sure Javascript Object data structure is correct and without errors. Use my data layer debugger bookmarklet to verify that the data is in the data layer. Also, keep an eye on the Javascript console and use jshint.com to make sure there are no errors and everything is formatted correctly.
- Try this cool method of inspecting each object that is pushed to the data layer is valid by using JSON.stringify to view Objects in the data layer. Just type the following command into your Javascript console and inspect the object in JSON (JavaScript Object Notation).
JSON.stringify(dataLayer[0]) // where 0 is the index of the first object in the data layer array
- Finally, Phone a Friend. Google Tag Manager and Google Analytics both have great Google+ communities and support sites. Check them out and ask for help!
Accessing Nested Values with Google Tag Manager Variables
When Google Analytics event hits carry Enhanced Ecommerce info, you may want to use a product’s attributes as the values for the event’s Category, Action, or Label or event Custom Dimension or Metric. Similarly, product data can be applied as a custom dimension on the pageview hit that, for example, is sent to on a product page to carry product detail view Enhanced Ecommerce information. In these case, if you are using Google Tag Manager, you can access the values of the product or actionField data using a Data Layer v2 Variable. These GTM Variables allow you to access property values that are nested within Objects or Arrays in the data layer.
For instance, if you wanted to access the name of a product that was just added to a shopping cart (as shown above), you would use the following format without the quotes: “ecommerce.add.products.0.name”. Note that the 0 is specifying the index (zero-based count) of the Object noted in the array that is enclosed in [brackets].
Thanks, Simo for getting me back on track with this.
A Note on Product Hit Scope Dimensions and Metrics
Custom Dimensions and Metrics are product level, and won’t be applied to an event or page on which the happen or to a user that interacts with them. That is done by setting the dimension or metric at the hit level. Just make sure to configure the hit Dimension or Metric accordingly. Check out this old but good explanation of hit scope by Justin Cutroni.
Start Collecting and Start Optimizing!
This may seem complicated, but the power that it provides is well worth time spent in a detailed implementation. Please leave a comment if you have any questions. Or send me an email at [email protected] and let’s get this started!
Thank you to SmartHome.com for the pretend data. I want everything in your store.