Intermediate Guide to Enhanced Ecommerce

I explained the benefits and measurement model of enhanced ecommerce in the “Getting Started with Enhanced Ecommerce” post a while back. Now we are going to delve a little deeper into the structure of enhanced ecommerce tracking code, covering all stages of the product life cycle and enabling the use of the enhanced ecommerce plug-in.

The enhanced ecommerce plug-in for analytics enables the measurement of user interactions with products on ecommerce websites across the user shopping experience including: product impressions, product clicks, viewing product details, adding a product to a shopping cart, flowing through the checkout process, transactions and refunds.

A. Migration and Compatibility with Ecommerce Plug-In

First, you should enable ecommerce tracking and enhanced ecommerce reporting in the View settings, along with defined funnel steps, as described in the “Getting Started Guide.

Then, you should enable the use of the enhanced ecommerce plug-in (“ec” in short). The enhanced ecommerce plug-in requires analytics.js library; that means the property must be updated to Universal Analytics. For even more detailed instructions on setting this up, refer to the Google Developers Page for Enhanced Ecommerce.

To check that Universal Analytics is enabled the following code snippet must be implemented:


To load the ec.js plug-in, the code above must be updated with a specific command
‘ga (‘require’, ‘ec’)’:


As shown above, the enhanced ecommerce plug-in should be loaded after creating a tracking object but before sending a hit to Google Analytics. The enhanced ecommerce plug-in should not be used alongside the ecommerce plug-in (‘ecommerce.js’) for the same property. If you have already set up ecommerce tracking but want to use enhanced ecommerce tracking, you have two options:

  1. Create a new property and enable enhanced ecommerce. In this case you should enable sending data from a single page to multiple properties.
  2. Migrate from the ecommerce plug-in to the enhanced ecommerce plug-in. In this case current analytics.js users should remove and replace references with enhanced ecommerce code. Transaction and item data previously collected using the ecommerce.js plug-in will not be affected by the migration and will remain available in the properties and profiles to which they were originally sent.

B. Measuring Ecommerce Activities

Now we are going to cover enhanced ecommerce tracking implementation by providing information as to how to go about measuring each stage of the product life cycle on a page-by-page and action-by-action basis. Enhanced ecommerce tracking can measure:

  1. Product impressions
  2. Clicks on product link
  3. Product detail views
  4. Addition and removals of products from shopping carts

This feature can also track the following activities:

  • Initiating the checkout process for a product group
  • Purchases and refunds
  • Impressions and clicks on internal promotions

1. Product Impression

To measure product impressions use the ‘ec:addImpression’ command. Details of the product viewed refer to the Impression Data type and is stored in ‘impressionFieldObject’.
For example, the code snippet below measures search result impressions on a product from users with first views of the product:


Only one of the variables (either ‘id’ or ‘name’) must be set, the others are optional.

2. Product Click

In a purchase funnel, a user may express interest in the particular product by clicking through to the product link from a list or category page. Product clicks are measured with the ‘ec:addProduct’ command and with a ‘ec:setAction’ to specify the type of action that has been performed. The data of the product clicked is stored in productFieldObject.
As an example, the following code measures a click on a product link displayed on a search result listing:


A productFieldObject must have a name or id value; all other values are optional.

3. Product Details View

In addition to product list impressions Enhanced Ecommerce supports product details page impressions. Which allows you to answer the following questions:

  • What percentage of visitors purchase after viewing product detail pages?
  • On average, how many products do users view before cart adds?

If a user views a product details page, a command ‘ec:addProduct’ is used alongside ‘ec:setAction’ to specify a ‘detail’ action. Here’s an example of tracking code that includes commands for creating a tracking object and loading ‘ec.js’ plug-in.


4. Shopping Cart Additions and Removals

After viewing a product page, a user may express her/his intent to buy the item(s) by adding it to a shopping cart. The data measured allows you answer the following question:

  • What percentage of visitors add products to their cart after viewing product pages?


To measure the addition or removal of a product from a shopping cart, a ‘ec:addProduct’ command is used alongside ‘ec:setAction’ and the type of action is set as ‘add’ or ‘remove’.
Bear in mind that the product information and add action must be sent alongside a Google Analytics Event (the action of removal is measured similarly):


You should tie the function ‘addToCart (product)’ via a JavaScript event handler onClick to the shopping cart add/remove button on each product detail page and the checkout page.

C. Measuring Checkout Process

Now that the user is ready to begin the checkout process, in order to measure each step in the checkout process you should:

  • Add tracking code that will measure each step of the checkout process
  • If applicable, add tracking code to measure checkout options
  • Optionally, set user-friendly step names for the checkout funnel report by configuring the ecommerce settings page in admin.

For each step in your checkout process, you’ll need to implement the corresponding tracking code that sends data to Google Analytics.

For each checkout step that you measure you should include a ‘step’ value. This value is used to map your checkout actions to the labels you configured at each step in the ecommerce settings page.

Ensure you have properly configured a checkout funnel on the ecommerce settings page. If you have additional information about the given checkout step at the time the step is measured, you can set the ‘option’ field with a ‘checkout’ action to capture this information. For example, the default payment type for users (e.g. ‘Visa’).

For measuring a checkout step a ‘ec:addProduct’ command is used for every product and the command ‘ec:setAction’ to indicate a checkout. On measuring, an event should be sent to Google Analytics containing product and checkout step information. This should be implemented on the link that proceeds each checkout step, to indicate the initiation of each step. ‘ec:setAction’ takes an ‘actionFieldObject’ to describe the checkout step with a number and additional information (about the default payment type for this user).

The following example shows how to measure the first step of a checkout process, with a single product, and some additional information about the payment type:


Checkout options allow you to measure additional information about the state of the checkout. This is particularly useful in cases where you have measured a checkout step during the initial pageview but additional information about the same checkout step is available after a user-selected option has been set. For example, the user selects a shipping method. To measure a checkout option, use ‘ec:setAction’ to indicate a ‘checkout_option’ and include the step number, and the option description.

You’ll likely want to measure this action once the user has clicked to move on to the next step in the checkout process. For example:


It is possible to track user flow through each step of the checkout process. When setting the action to checkout, you will need to pass the step number and label of each step. The steps and label will appear in the GA report. Note that multiple checkout steps cannot be sent in a single hit. If multiple steps appear on a single page, each will need to be sent with a separate pageview or event.

Measuring the checkout process allows you to answer the following questions:

  • Where are users dropping off in the checkout funnel?
  • How do shipping options affect checkout rates?

D. Measuring Transactions

A user completes the checkout process by making a purchase. In order to measure transactions, use ‘ec:addProduct’ for each product and the ‘ec:setAction’ command with the action type set to ‘purchase’. Transaction level information like total revenue, tax, etc. can be specified via an ‘actionFieldObject’.

The following tracking code can be used on the order confirmation page:


Measuring transactions enable you track Revenue, Transactions, Average Value per Transaction, and Average Items per Transaction.

E. Measuring Refunds

In a scenario where a customer asks for a refund, refunds may either be full (refunding the entire order) or partial (refunding a part of the order) e.g. refunding a single product. To refund an entire transaction, set a ‘refund’ action and provide the transaction ID:


If a matching transaction is not found, the ‘refund’ hit will not be processed. Transactions may only be refunded in Google Analytics within 6 months of the original reported transaction date.

In order to measure partial refund use the ‘ec:setAction’ and ‘ec:addProduct’ commands, set the action type to ‘refund’, then provide the transaction ID, product ID(s) and product quantities to be refunded:


F. Measuring Internal Promotions

Google Analytics Enhanced Ecommerce supports the measurement of impressions and clicks on internal promotions such as banners, exit pop-ups, sales announcements, temporary offers and seasonal promotions typically displayed alongside related products or the home page.
Measuring internal promotions allows you answer the following questions:

  • Do seasonal homepage promotions drive sales to specific product categories?
  • Are users clicking through promotional offers and making purchases?

1. Promotion Impressions

Internal promotion impressions are generally measured at page load and are sent with the initial pageview using the ‘ec:addPromo’ command. Promotion details are added in ‘promoFieldObject’.

A ‘promoFieldObject’ must have a name or id value; all other values are optional. For example:


2. Promotion Clicks

In order to measure clicks on an internal promotion campaign, use the ‘ec:addPromo’ command, ‘ec:setAction’ command and set the action type to ‘promo_click':


There are two things to note about this method:

  1. Do not send product data with promo clicks. Product data should be set with a separate hit.
  2. Internal promotion campaign clicks should be sent as a separate hit after internal promotion impressions data has been passed.

For example, to measure a product detail page with an impression and a promo click, first send product and impression data with the initial pageview, then send promo click data in a separate event:



Ecommerce tracking can either be sent with a Google Analytics pageview or event. It is generally recommended to send impression information with a pageview, and click actions with an event.


  1. If ecommerce information may delay the initial pageview of a page, the data can be sent with an event. For impressions, it is recommended to set events to non-interactive.
  2. When sending events for Ecommerce actions, use a data model for easier analysis. For example, the category for all ecommerce events can be set to ‘ecommerce’.
  3. If ecommerce information will never be sent with the initial pageview, then the plug-in call may be moved after the pageview.
  4. Google Analytics includes a limit of 500 hits per session. When sending ecommerce tracking information, ensure that the total number of pageviews and events do not exceed 500 hits in a typical user visit.
  5. In addition, there is a 8192 byte limit per hit – if the total number of product impressions (and promotions, transactions, etc.) exceeds this limit, use Product ID Dimension Widening to send optional product parameters.

In order to indicate how product information should be interpreted, all ‘ec:addProduct’ calls need to be followed by ‘ec:setAction’.

Enhanced Ecommerce enables the measurement of users’ interactions with products during the product life cycle. It provides a comprehensive overview visitor behavior patterns in the shopping process.

Understanding behavioral trends of potential customers is vital to running an ecommerce business to scale. That is why enhanced ecommerce should be thoroughly configured and its data correctly interpreted.

Let me know how you progress with configuring enhanced ecommerce in your store.

Every 2 weeks, get the best ecommerce tips and latest trends in your inbox.

By submitting this form, I agree to the data entered being used by PrestaShop S.A for sending newsletters and promotional offers. You can unsubscribe at any time by using the link in the emails sent to you. Learn more about managing your data and rights.