The names of some ecommerce events and parameters have changed for Google Analytics 4 properties. Using the correct GA4 names and parameters will give you the most useful ecommerce reporting and ecommerce event data in your GA4 property.
To migrate from UA to GA4, you should
- Leave your UA implementation unchanged
- Create duplicate events for your GA4 property. Use the new event names and parameters that are required for Google Analytics properties. You will have two independent implementations side by side, each doing slightly different things.
Avoid sharing ecommerce implementations across UA and GA4
If you use your existing UA ecommerce implementation (i.e. dataLayer events and gtag.js code) with a GA4 property, your GA4 ecommerce reports will not be complete. The gtag.js library automatically translates some, but not all of the UA event and parameters to what is needed for GA4.
On the other hand, you should not simply switch to the GA4 event and parameter names either. UA will not collect any data for events that it doesn't recognize. For example, all GA4 ecommerce events have the parameter item_id
instead of id
.
Because of this, the best practice is to have two implementations in place: one for UA and one for your GA4 property.
Since this will result in sending two events where you would ordinarily only send a single event, you may decide to rely on your UA implementation, and add only the additional events/ parameters required to send data to GA4 properties. However, this requires a deep understanding of the two different sets of events and parameters. If you keep your UA dataLayer structure and objects,
- You'll need to add new GA4 events/ parameters to access the full reporting capabilities in GA4 properties
- Where a UA event has been deprecated in GA4, you should create a duplicate event with the updated GA4 name
Basics: events and parameters
An event specifies how to interpret the product, list, and/or promotion data that you send. Parameters pass more specific information about an event.
- For GA4, parameters are embedded in an
items
array (details). Note that this is different from the UA dataLayer where additional action information was required to be specified for distinct events. - Ecommerce tagging is subject to GA4 event and parameter limitations. You can specify up to 25 custom parameters per event (the
items
array only takes up one slot) and up to 50 custom dimensions and 50 custom metrics per project (details).
Required parameters for GA4 ecommerce
(required parameters in bold)
If you do not include the required parameters for ecommerce-specific events (e.g. items
, item_id
, item_name
), these events will not show up in your GA4 ecommerce reports. Instead, they will be reported as custom events.
Event Parameter |
Item-level Parameters |
Items (see below) |
affiliation, coupon, currency, discount, index, item_id, item_brand, item_category, item_category2, item_category3, item_category4, item_category5, item_list_name, item_list_id, item_name, item_variant, price, quantity |
The following table describes the individual items array parameters that are available for collection.
Items array parameter name |
Description |
affiliation |
The name or code of the affiliate (partner/vendor; if any) associated with an individual item |
coupon |
The coupon name/code (if any) associated with an individual item |
discount |
The discount (if any) associated with an individual item |
item_brand |
The brand of the item |
item_category |
The category of the item |
item_category2 |
The second category hierarchy or additional taxonomy for the item |
item_category3 |
The third category hierarchy or additional taxonomy for the item |
item_category4 |
The fourth category hierarchy or additional taxonomy for the item |
item_category5 |
The fifth category hierarchy or additional taxonomy for the item |
item_id |
The id of the item (required) |
item_name |
The name of the item (required) |
item_variant |
The item variant or unique code or description for additional item details/options |
price |
The price of the item |
quantity |
The quantity of the item being interacted with |
Mapping across UA and GA4
Some names have changed, for example, the data layer parameters that used to be “impression” or “product” are now consolidated into items
.
There is now an items
array.
How to use this table:
- Compare the event changes (column A vs column C)
- Review the dimension/parameter requirements and changes (column B vs column D). Note the additional table below that highlights the changes in parameters for items/ products
- If you have an app with Firebase, note the following changes to event names and make the corresponding changes to match GA4 event names (column C). Any new ecommerce-specific reporting in GA4 properties will not appear in the Firebase interface. Additionally, the Firebase version of detailed event reports, for
ecommerce_purchase
andpurchase
for instance, may not be updated.- Changed
ecommerce_purchase
(Google Analytics for Firebase) ->purchase
ecommerce_refund
(Google Analytics for Firebase) ->refund
select_content
(Google Analytics for Firebase) ->select_item
present_offer
(Google Analytics for Firebase) ->select_promotion
- New
view_cart
- Changed
Column A UA event names (reference) |
Column B UA dimensions (reference) |
Column C GA4 event names (reference) |
Column D GA4 parameters (reference) |
|
id coupon revenue tax shipping currencyCode **products (see detail below) |
|
transaction_id coupon value tax shipping currency **items (see detail below) |
|
option |
|
payment_type |
|
revenue currencyCode option |
|
price currency shipping_tier |
|
currencyCode revenue coupon step (analytics.js only) option (analytics.js only) **products |
|
currency value coupon **items |
N/A
N/A |
currencyCode revenue **products |
|
currency value **items |
|
currencyCode **products revenue |
|
currency **items value |
productClick |
list N/A - did not exist **products |
|
item_list_name item_list_id **items |
|
id name creative position **products |
|
promotion_id promotion_name creative_name creative_slot **items |
*New or changed event name from UA
Detail |
GA4 parameters |
Corresponding UA dimensions |
**Items/Products detail |
items item_id item_name item_brand item_category item_category2 item_category3 item_category4 item_category5 item_variant affiliation discount coupon price quantity |
products id name brand category N/A - did not exist N/A - did not exist N/A - did not exist N/A - did not exist variant N/A - did not exist N/A - did not exist coupon price quantity |
The following event names in UA are considered ecommerce events in GA4 properties:
purchase
refund
begin_checkout
add_to_cart
remove_from_cart
view_cart
add_to_wishlist
view_item
*view_promotion
select_promotion
select_item*
view_item_list
add_payment_info
add_shipping_info
- * These events support only a single item.
When one of the above events is sent to a GA4 property via the gtag.js API, GA4 ecommerce event processing will look for an items
key in the event model. If found, the parameter will be parsed as an array of up to 200 items, where each item is an object with a predefined schema. For each item, GA4 ecommerce will transmit data in any field from a predefined list. The following will be the initial predefined fields for an item:
- item_id
- item_name
- item_brand
- item_category
- item_category2
- item_category3
- item_category4
- item_category5
- item_variant
- price
- quantity
- coupon
- index
- item_list_name
- item_list_id
- discount
- affiliation
- location_id
- promotion_id (event or item level; item takes precedence)
- promotion_name (event or item level; item takes precedence)
- creative_name (event or item level; item takes precedence)
- creative_slot (event or item level; item takes precedence)
If you don't update your event instrumentation from UA, you will no longer see the following events in your GA4 ecommerce reports, because the old event names won't be recognized. Create a duplicate event with the correct name for your GA4 property.
set_checkout_option
(this is merged with begin_checkout in GA4)checkout_progress
(this is merged with begin_checkout in GA4)select_content
(this is no longer a GA4 ecommerce event, but still a recommended event, without support for items array)
GA4 properties introduce additional item-level parameters, eg. affiliation, currency, and a few item_category parameters. You will not get the benefits of these additional parameters if you don't retag. However, these additional parameters are optional and won't break if you don't use them.
Updating the dataLayer for Google Tag Manager
To take advantage of new events introduced for GA4 properties, you'll need to add new events/ parameters in the dataLayer and also need to add new event triggers in Google Tag Manager.
- You will have the choice to manually determine which datalayer key to map to a specified event parameter.
- For example, in UA you must push "
id
" (of the purchase event) in the dataLayer object as "ecommerce.purchase.actionField.id
". With GA4, you can specify the dataLayer key to map to the "transaction_id
" event parameter. If you re-used the UA dataLayer object, you can create a Google Tag Manager dataLayer variable mapped to the key "ecommerce.purchase.actionField.id
" and assign it to the GA4 event as "transaction_id
". Or, you can map the Google Tag Manager datalayer variable to the key "ecommerce.purchase.transaction_id
", and assign it to the event parameter "transaction_id
".
- For example, in UA you must push "
- You have the option to continue to reference existing dataLayer objects
- If you leverage existing dataLayer objects from your UA implementation, you cannot take advantage of the new GA4 event names and parameters (e.g., additional
item
level params). But, you will get some ecommerce reporting for existing events if you manually create the necessary variables in Tag Manager.
- If you leverage existing dataLayer objects from your UA implementation, you cannot take advantage of the new GA4 event names and parameters (e.g., additional
items
’ and value {{ecommerce.purchase.products}}
, where {{ecommerce.purchase.products}}
is a Tag Manager dataLayer variable that needs to be created to read the products array from the dataLayer. You need to create a dataLayer variable for each event-level parameter and assign it to an event parameter, and then repeat for each ecommerce event. See the example below for details.
UA Google Tag Manager dataLayer push code (reference) |
GA4 Google Tag Manager implementation re-using existing dataLayer implemented for UA |
|
You need to create datalayer variables for each event-level parameter, like this below. You need to repeat this for each ecommerce event you track. |
Implementation examples
Setting up the purchase funnel
There are typically four steps in a purchase funnel:
View products
User views an item or a list of items. To measure item list views/impressions, push a list of items to the dataLayer and collect an event along with that data.
- gtag.js
- Event:
view_item_list
ORview_item
- In UA, the equivalent event is “
impressions
”
- In UA, the equivalent event is “
- Parameters: must include at least
item_id
ORitem_name
- In UA, parameters did not have the prefix “
item_
”; “list_position
” is now “index
’
- In UA, parameters did not have the prefix “
- Event:
- Google Tag Manager
- Event:
view_item_list
ORview_item
- In UA, the equivalent event is “
impressions
”
- In UA, the equivalent event is “
- Parameters: items is a data layer variable “
ecommerce.items
”; The parameters are “items{ }
” and must include at leastitem_id
ORitem_name
- In UA, parameters did not have the prefix “
item_
”; “position
” is now “index
’
- In UA, parameters did not have the prefix “
- Event:
Add to cart
User selects an item and adds it to their cart. Variations of this could include adding to a wishlist or sending a request for more information.
- gtag.js
- Event:
add_to_cart
- Parameters: must include at least
item_id
ORitem_name
- Event:
- Google Tag Manager
- Event:
add_to_cart
- In UA, the equivalent dataLayer event is “
addToCart
” and this required an additional actionFieldObject “add”; actionFieldObject is no longer required in the dataLayer object for GA4.
- In UA, the equivalent dataLayer event is “
- Parameters: as part of “
items
”, must include at leastitem_id
ORitem_name
- In UA, this required the separate variable “
products
” for product info
- In UA, this required the separate variable “
- Event:
Checkout
User goes to their cart with an item and begins the checkout process. Additional steps such as adding payment or shipping information have their own GA4 events. If your checkout flow includes these additional steps, be sure to send specific events for them so that they can be included in your purchase funnel.
- gtag.js
- Event:
begin_checkout
- In UA, there are also events for ‘
checkout_progress
” and “set_checkout_option
” which are not available in GA4 properties, instead, see specific events foradd_to_cart
,add_shipping_info
, andadd_payment_info
.
- In UA, there are also events for ‘
- Parameters: must include at least
item_id
ORitem_name
- Event:
- Google Tag Manager
- Event:
begin_checkout
- In UA, the equivalent dataLayer event is “
checkout
” and this required an additional actionFieldObject “checkout”. This actionField is not needed in GA4, however you shouldn’t change your existing implementation, otherwise you will break ecommerce in UA.
- In UA, the equivalent dataLayer event is “
- Parameters: as part of “items”, must include at least
item_id
ORitem_name
-
In UA this required the separate variable “products” for product info
-
- Event:
Purchase
User makes a purchase
- In GA4 properties, this event is automatically marked as a conversion once it has been added to your code
- gtag.js
- Event:
purchase
- In UA, there are also events for ‘
checkout_progress
” and “set_checkout_option
” which are not yet available in GA4 properties
- In UA, there are also events for ‘
- Parameters: must include at least
transaction_id
- Event:
UA - analytics.js |
UA - gtag.js |
GA4 Properties - gtag.js |
|
|
|
analytics.js uses enhanced ecommerce to set a productFieldObject to specify product details as well as an actionFieldObject to specify the action occurring. The migration to gtag.js introduces fundamental differences. There is only one event that is automatically logged as ecommerce; both the transaction and product information can be included; product information can be sent in an array (as opposed to requiring additional events). |
Send a purchase event with the items in the transaction. The naming for required values is different, such as “id” moving to “item_id” and “name” moving to “item_name.” There are also differences in optional values that should be observed. |
Send a purchase event with the items in the transaction |
- Google Tag Manager
- Event:
purchase
- In UA, the equivalent event data layer event is “
purchase
”; requires an action field for the full transaction
- In UA, the equivalent event data layer event is “
- Parameters: as part of “
items
”, must include at leastitem_id
ORitem_name
- In UA this required the separate variable “products” for product info
- Event:
UA - Tag Manager |
GA4 Properties - gtag.js |
|
|
Push your transaction details into the dataLayer using the purchase action, along with an event that will fire an enhanced ecommerce-enabled tag. Send transaction data with a pageview if available when the page loads. Otherwise, use an event when the transaction data becomes available. Notable Changes:
|
To measure transactions, push a list of items to the data layer and collect a |
Additional ecommerce activities
GA4 properties can capture additional information as well:
- Highlight an incentive that was associated with an item or event
- Coupon enables you to specify the name of any coupon associated with an item (eg free shipping, or 20% one item); data type is string and this is an item parameter
- Discount (new) enables you to specify the monetary value of the discount associated with an item (eg “0.05”); data type is float
- Promotion - these include on-site messaging to direct a user to a specific section of your site/ app
- Requires a
promotion_id
orpromotion_name
; otherwise, data will only be available in the standard events table reports - To attribute a purchase to a promotion, you need to add either the
promotion_id
orpromotion_name
parameter at the item or item-list level of every ecommerce event.
- Requires a
- Refunds - measure a refund of a transaction
- Refund is a specific event that can handle full or partial refunds
- Requires a
transaction_id
, otherwise, data will only be available in the standard events table reports