I am busy with implementing the GA4 ecommerce dataLayer
in my WooCommerce site. There are a few plug-ins which can implement the dataLayer
for Universal Analytics (e.g. this one, for $99 per year), but I can’t find anything for GA4.
This is the dataLayer
for the purchase
event (source):
dataLayer.push({
'event': 'purchase',
'ecommerce': {
'purchase': {
'transaction_id': 'T12345',
'affiliation': 'Online Store',
'value': '35.43',
'tax': '4.90',
'shipping': '5.99',
'currency': 'EUR',
'coupon': 'SUMMER_SALE',
'items': [{
'item_name': 'Triblend Android T-Shirt',
'item_id': '12345',
'item_price': '15.25',
'item_brand': 'Google',
'item_category': 'Apparel',
'item_variant': 'Gray',
'quantity': 1,
'item_coupon': ''
}, {
'item_name': 'Donut Friday Scented T-Shirt',
'item_id': '67890',
'item_price': '33.75',
'item_brand': 'Google',
'item_category': 'Apparel',
'item_variant': 'Black',
'quantity': 1
}]
}
}
});
Can anyone help me out to put the variables in it?
2
Answers
Found it already i guess:
Just in case anyone else needs a WordPress plugin that can integrate WooCommerce with GA4. There is a solution that can do that using Google Tag Manager:
https://wordpress.org/plugins/gtm-ecommerce-woo/
It covers the purchase and add_to_cart events and takes care of populating those values.