WooCommerce Enhanced Ecommerce (UA) Tracking with GTM
Will go through a straightforward and very simple method of enabling Google Analytics (UA) Enhanced Ecommerce with WooCommerce
We will do the implementation using the most popular plugin for GTM - GTM4WP developed by Thomas Geiger
Let's get started:
1️⃣ Install GTM4WP
From WordPress > Add New Plugin and Search for GTM. Select the one you see with the name "Google Tag Manager for WordPress" and install.
2️⃣ Enable the Plugin
Now enable the plugin and enter your GTM ID to the ID field.
A few options are available for container placement, including an automatic footer placement. I prefer mostly to go for the last option [off] to have only data layers and install the GTM script at header manually.
2️⃣ Enable Woocommerce Integration
Now navigate to the "Integration" tab and select "Woo Commerce". From here enable "Track enhanced e-commerce" and save. Remember to clear/purge cache if there is are caching plugins active.
3️⃣ Check if data layers are working
Have check if your data layers are working at few parts, you can do this without enabling preview mode too, by entering dataLayer
to chrome console.
In the below screenshot I am have tested at product page and found the data layers for product view.
4️⃣ GTM Setup - Create GA ID variable
Now that dataLayers are working and the WooCommerce setup is complete, move over to GTM to set up and start with creating a Google Analytics variable specifically for EEC TRACKING. This is to make sure normal Google Analytics codes may not come in conflict with EEC data layers.
Create variable and enable the "Enhanced Ecommerce" feature and select the "Use Data Layer" option by expanding the "More Settings" Tag option.
5️⃣ GTM - Create a new Universal Analytics tag
Now create a Universal Analytics tag like below with the event category as "EEC" and event action as event name variable {{Event}}
⚠️Update "Non-Interaction Hit" to "True" to make sure bounce rates are not affected.
6️⃣ Create Trigger
Now create a REGEX enabled custom event trigger as below and enter the following:
gtm4wp.productClickEEC|gtm4wp.addProductToCartEEC|gtm4wp.removeFromCartEEC|gtm4wp.checkoutOptionEEC|gtm4wp.checkoutStepEEC|gtm4wp.orderCompletedEEC|gtm4wp.productImpressionEEC|gtm4wp.changeDetailViewEEC
Do not forget to enable "Use regex matching"
7️⃣ Enable Ecommerce at Google Analytics settings
Now at Google Analytics, view settings, enable eCommerce and opt for enhanced e-commerce.
8️⃣ Publish GTM
Publish GTM and we're DONE!
Start testing for events and make sure everything works.