For eCommerce clients, the transition to GA4 from UA may seem daunting, especially if enhanced eComm tracking was set up in your UA account before this transition as it will not transfer over to GA4 absent modification. However, we have a rather quick and simple method for adding enhanced eCommerce tracking to your new GA4 property that involves setting up just two components and requires no coding. One item to set up is a prebuilt container you will import into your GTM account, and the second item is a plugin that adds measurement of eCommerce data to the GTM
dataLayer.
STEP 1. INSTALL THE GTM4WP PLUGIN & SET IT UP
The first component of this setup is installation and setup of a free WordPress plugin, Google Tag Manager 4 WordPress. You can find this plugin in the WordPress Plugin Directory or you can go to gtm4wp.com and download the plugin directly. Again, it is a free plugin, and no premium services are required. The plugin adds enhanced eCommerce data to the dataLayer, making measurement in GTM easier. Step-by-step instructions are below:
- Download the Plugin. You can download the plugin from the GTM4WP plugin directly from the plugin’s dedicated website, or you can access the WordPress Plugin Directory from your site’s WordPress admin dashboard and download it directly to the site (Image 10.). If you are unfamiliar with adding plugins to your site, you can refer to the instructions in Hubspot’s How to Install, Add, and Use WordPress Plugins article.
- Activate & Set Up Container Settings. After you’ve installed your plugin, activate it. Once activated, access “Settings” in the lefthand sidebar of your WP admin dashboard, and then select “Google Tag Manager” from the submenu items. This will take you to the dashboard for your GTM4WP plugin where you can adjust setup/settings. Once on the Google Tag Manager for Wordpress options screen, you will need to perform a couple minor edits to complete setup. There are two methods for this, both are extremely simple:
- Setup 1, GTM Container Added to <head> Tag – if you’re GTM container was applied to your site by adding the necessary GTM tags to your website’s <head> tag, set up the plugin like below
Insert your Google Tag Manager account ID number (will begin with “GTM-“ followed by six alpha-numeric characters), turn “Container code ON/OFF” to Off, and set “Container code compatibility mode” to Off. These settings ONLY apply if you have implemented the GTM container via your website’s <head> tag. - Setup 2, GTM Container Not Added to <head> Tag – if you lack the coding chops or WordPress familiarity to add your GTM container tags to your website’s <head>, don’t fret. You can use this plugin to set your container up. Simply enter your GTM account ID number, turn “Container code ON/OFF” to On, and set “Container code compatibility mode” to Footer of the page. Your GTM container will be applied to your site, and the plugin is ready to measure enhanced eComm data in GA4 using the GTM dataLayer.
- Turn on Tracking for Enhanced eCommerce. Once you’ve added, activated, and set up the container information in the plugin, you will need to activate tracking for enhanced eCommerce. To do this, regardless of how you set up the container above, follow these instructions:
- Directions for Turning on Tracking for Enhanced eCommerce – click the “Integration” tab on the GTM4WP plugin dashboard, and the select “WooCommerce” (small blue-text link below the tabs at the top of the GTM4WP plugin dashboard). Click the checkbox next to “Track enhanced e-commerce” and then click the blue “Save Changes” button at the bottom of the screen. Voila! The GTM4WP is now ready to transmit enhanced eComm data via your GTM dataLayer to your GA4 account, and you simply need to complete setup of the enhanced eComm items in your GTM account to begin recording that data in GA4.
STEP 2. DOWNLOAD GTM4WP DOCUMENT & SETUP ENHANCED ECOMM TAGS, TRIGGERS, AND VARIABLES
Once the above plugin is installed, activated, and set up correctly based on how you want to implement your GTM container (viaor the plugin), you’ll need to set up the variables, tags, and triggers in GTM that will allow you to capture enhanced eComm data transmitted from your website and record it in GA4.
The below document, created specifically for use with the
Google Tag Manager 4 WordPress plugin, uses recommended event names from Google to transmit eCommerce events like add to cart, purchase, and more to Google Analytics 4. When you upload the document into GTM, you’re actually importing a new container with the necessary tags, variables, and triggers required for enhanced eComm tracking in GTM/GA4 almost fully set up and ready for use out-of-the-box. It doesn’t get much simpler or easier than that.
Download the GTM4WP Container Document for Enhanced eCommerceGTM4WP Enhanced eCommerce Container TemplateImport the Container
After you’ve downloaded the above document, log in to your Google Tag Manager account, proceed to the Admin tab, and then select “Import Container” from the Container column
Once you’ve clicked “Import Container”, you’ll see the following screen (Image 13.). Here, you will need to adjust settings to import the new tags without overwriting conflicting tags already present in your GTM account, and to ensure you can merge the new workspace you’ll be creating with your current/default workspace. Workspaces in GTM allow you to create new containers, tags, etc. without impacting the live workspace.
Be sure to set the above settings as follows:
- Import the downloaded JSON file created by GTM4WP
- Create a new workspace and name as desired
- Choose “Merge” under the import options
- Choose “Rename” conflicting tags, triggers, and variables under the merge options
After you’ve applied the above settings, you should see the Tags, Triggers, Variables, and Templates modules with numbers above “New” on each module but Templates. If you see an indicator that Tags, Triggers, or Variables will be modified or deleted, check your settings for the container import and adjust as needed. Unless you have an issue with conflicting tag, trigger, or variable names, “New” should be the only column showing items. Click the “Confirm” button once the setup is complete.
Complete Set Up of Enhanced eCommerce Tags, Triggers, and Variables
More set up?! Yep, but don’t worry, this is very quick. Once you’ve clicked the “Confirm” button on the Import Container screen (assuming your settings are correct), you’ll be redirected to your new workspace. Your current workspace can be seen just below the “Workspace” link on your GTM account’s main menu – you should be able to see your default workspace and the newly created workspace with the name you applied.
- Tags – when you view your tags now, you’ll see a new “GA4 – Event – Ecommerce Events” tag. Completing setup of the tag is extremely simple as the container import already created the necessary triggers and variables for the tag. To complete set up of the tag, do the following:
- Access your GTM tags via the “Tags” link on the lefthand sidebar of your GTM home screen, and select “GA4 – Event - Ecommerce Events”
- You’ll see light-grey text on the “GA4 – Event – Ecommerce Events” tag edit screen that says “Configuration Tag”. If there is not a dropdown field below this light-grey text, click the text and one will appear. Select the GA4 On-page Tag you created earlier that links your GA4 account to your GTM account. You should have named it something akin to “GA4 Config Tag” or “GA4 Configuration Tag”
- You do not need to adjust any other settings on the “Tag Configuration” module, and a trigger should already be annotated by default (Event – Ecommerce Events GA4)
- Save the revised tag configuration
Once you’ve set up the GA4 – Event – Ecommerce Events tag, switch from your new workspace back to your Default Workspace and click the blue “Submit” button in the upper righthand corner of your GTM home screen. This will publish all your edits/changes to your GTM container and make them live.
NOTE: You may see a warning that says “This workspace is out of date. It will be updated automatically if you proceed” when you click “Submit”. This is perfectly fine, and desired. Click the blue “Publish” button. Your Default Workspace will update with the new tags, triggers, and variables from the new container you imported and edited.