There are two main types of Universal Analytics ecommerce implementation methods: Standard ecommerce and enhanced ecommerce.
Standard ecommerce reports allow you to measure transactions and analyze purchase activity on your site or app. You can see product and transaction information, average order value, ecommerce conversion rate, time to purchase, and other data.
Enhanced ecommerce adds additional functionality to standard ecommerce reports. Enhanced ecommerce shows when customers added items to their shopping carts, when they started the checkout process, and when they completed a purchase. You can also use enhanced ecommerce to identify segments of customers who fall out of the shopping funnel.
These instructions describe how to use Google Tag Manager to implement Universal Analytics ecommerce tags.
Standard Ecommerce
To set up a standard Universal Analytics ecommerce tag:
- Login to your Google Analytics Account and enable ecommerce for the view you want.
- Create a Universal Analytics tag and set the Track Type to Transaction.
- Configure your tag with the required fields.
- Add the
dataLayer()
object to the transaction page to collect and pass the required variables. Make sure thedataLayer()
variables are populated in code before the tag fires. - Create a trigger to fire the tag on the transaction confirmation page.
All the transaction information should be passed via the data layer, with the variable names shown below:
Transaction Data
Variable Name | Description | Type |
---|---|---|
transactionId (Required) | Unique transaction identifier | string |
transactionAffiliation (Optional) | Partner or store | string |
transactionTotal (Required) | Total value of the transaction | numeric |
transactionShipping (Optional) | Shipping charge for the transaction | numeric |
transactionTax (Optional) | Tax amount for the transaction | numeric |
transactionProducts (Optional) | List of items purchased in the transaction | array of product objects |
Product Data
Variable Name | Description | Type |
---|---|---|
name (Required) | Product name | string |
sku (Required) | Product SKU | string |
category (Optional) | Product category | string |
price (Required) | Unit price | numeric |
quantity (Required) | Number of items | numeric |
Place this code above the Tag Manager container snippet so that the data layer is ready when Tag Manager fires the Google Analytics tag.
If for some reason you can’t place the ecommerce data above the Tag Manager container snippet, you can try one of these solutions:
- Have the tag fire based on a custom event farther down the page (e.g. combine the data and the event push as described in the developer documentation.)
- Set the trigger type to “DOM Ready”.
Learn more about Google Analytics ecommerce.
Enhanced Ecommerce
There are two methods that are used to implement enhanced ecommerce with Tag Manager:
- Data layer: The preferred method; push ecommerce data to the data layer from your code.
- Custom JavaScript variable: Create a Custom JavaScript variable in Tag Manager. This variable should return an object with the information that you would otherwise push onto the data layer.
With either method, you should first become familiar with enhanced ecommerce in the Google Analytics before you use Tag Manager to implement enhanced ecommerce tags. You may need to enlist the help of a developer for your data layer implementation.
Important: There are several specific types of information that are available to work with in enhanced ecommerce implementations. Please refer to the developer documentation for a complete list of data types that are supported.
Data layer implementation
- In your code, add the ecommerce information to a data layer object called "ecommerce". Refer to the Tag Manager developer documentation for details on how to implement a data layer.
- In Tag Manager, create a Universal Analytics tag with these additional settings:
- Set the Track Type to either Page View or Event.
- In the Google Analytics Settings variable, under More Settings Ecommerce, set Enable Enhanced Ecommerce Features to True.
- Select Use Data Layer.
Custom JavaScript variable implementation
- Create a Custom JavaScript variable. This variable must return an object that contains the ecommerce object.
In this variable, use the same syntax that would be used to push this data onto the data layer. - In Tag Manager, create a Universal Analytics tag with these additional settings:
- Set the Track Type to either Page View or Event.
- In the Google Analytics Settings variable, under More Settings Advertising, set Enable Enhanced Ecommerce Features to True.
- Select Use Data Layer.