with sunset notice Writing an article about the universal analytics service certainly seems like a waste of time.
However, with recent updates Google Tag Manager This is interesting and should ease the burden for Google Analytics users trying to double tag their sites with both Universal Analytics and Google Analytics 4. When Those who want to take advantage of the new features of GA4 data layer schema.
This article provides a brief overview of the new features. Use GA4 schema The option is in Google Tag Manager’s Universal Analytics tag (found in your eCommerce settings).
X
shimmer newsletter
Subscribe to our Simmer newsletter to receive the latest news and content from Simo Ahava right in your email inbox!
when you go to e-commerce Configure Universal Analytics tags and sets Enable enhanced ecommerce features If true, the new checkbox will be displayed. Use GA4 schema.
This checkbox Use data layer Also read data from variable option.
Selecting this checkbox indicates that the tag should parse ecommerce data. GA4 schema not Semantics of Universal Analytics.
This is a useful option if you want to go all out and implement a GA4 data layer on your site.
for Use data layer A correctly formatted GA4 ecommerce object is dataLayer
When the Universal Analytics tag triggers.You can find schema descriptions for various GA4 events here.
For example, a valid GA4 is: purchase dataLayer
The object looks like this:
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: 'purchase',
ecommerce: {
transaction_id: 'T12345',
value: '10.00',
tax: '2.40',
shipping: '5.50',
currency: 'EUR',
items: [{
item_id: 'bigshirt1',
item_name: 'Very Big Shirt',
item_category: 'shirts',
item_category2: 'big',
price: '10.00',
quantity: 1
}]
}
});
Triggering the Universal Analytics tag ( Use GA4 schema In this message, the outgoing payload looks like this:
It’s pretty good! As expected, all relevant fields mapped to the corresponding fields in the UA hit.The parser does some nice magic like combining item_category
When item_category2
into a two-level category structure separated by /
.
if you choose read data from variable For options, you should choose a variable that returns an object with the same schema as above (so whatever the object contains ecommerce
schema).
Notes
for Use data layer option to work, the value of event
key Must Must be a GA4 ecommerce event name. Only then will the Universal Analytics tags map correctly. Here is the event name mapping (based on limited testing):
event name at dataLayer |
Map to UA Action | Note |
---|---|---|
view_promotion |
none | map items The contents of the array to UA promotion keys. |
select_promotion |
none | map items Set the contents of the array to the UA escalation key, promoa=click parameter. |
view_item_list |
none | map items The contents of the array to UA impression keys. |
select_item |
click |
map items Convert the contents of the array to a UA product key. |
view_item |
detail |
See previous. |
add_to_cart |
add |
See previous. |
remove_from_cart |
remove |
See previous. |
begin_checkout |
checkout |
See previous. Do not fill in the checkout step. |
purchase |
purchase |
See previous. It also sets all transaction keys from their respective keys in the push. |
refund |
refund |
See previous. It also sets all transaction keys from their respective keys in the push. |
Please note the bug in begin_checkout
event.I was expecting to at least enter a value in the checkout step 1
Outgoing hit, but not in the payload. Also, I don’t think it’s possible to send additional checkout steps as there is no event corresponding to any checkout step in the GA4 schema (add_shipping_info
When add_payment_info
not mapped to UA ecommerce actions).
Product-scoped custom dimensions and metrics is mapped as long as they are dimensionX
When metricX
format with items
An array of GA4 ecommerce objects. This is because it is somewhat counterproductive when building a GA4 e-commerce. dataLayer
I find this useful that’s all When retrieving data from a variable.
GA4 treats promotions and impressions as its own, items
Impressions and Promotions cannot be combined with Ecommerce Actions in the mapped Universal Analytics object due to the use of arrays. This means you will get more hits than you would with Universal Analytics. dataLayer
schema.
Given all the caveats above, I’m not convinced it makes sense to take advantage of this feature unless you’re unwilling to accept some compromises in your Universal Analytics Enhanced Ecommerce collection.it might be better to keep Use GA4 schema Uncheck and tune your enhanced ecommerce payload with some variables that allow you to do the GA4 -> UA mapping manually, choosing the parameters and values you need 100%.
But for busy people who just want to get data to UAs without having to keep the “old” enhanced ecommerce dataLayer
On the site, this feature is worth taking a closer look.