Search…
Magento 2 Google Tag Manager (GTM) GA4 Enhanced Ecommerce Tracking

Table of Contents
  1. 1.
    • Installation via app/code
    • Installation via Composer
  2. 2.
    • General Settings
    • Checkout Behaviour
  3. 3.
    • General Settings
    • Cookies From Query Params
  4. 10.
    • Enable Enhanced Conversions in Google Adwords
    • Set up Enhanced Conversion with the Module
  5. 14.
    • Order Total of Product without VAT
    • Order Total of Product with VAT
    • Send SKU of Child Product
    • Send SKU of Parent Product Only
    • Send Parent Category
    • Primary Category

  • Installation via app/code: Upload the content of the module to your root folder. This will not overwrite the existing Magento folder or files, only the new contents will be added. After the successful upload of the package, run below commands on Magento 2 root directory.
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy
  • Installation via Composer: Please follow the guide provided in the below link to complete the installation via composer.

Go to Admin > Stores > Configuration > Scommerce Configuration > Tracking Base

  • Enabled – Select “Yes” or “No” to enable or disable the module.
  • Enable Enhanced Ecommerce – Select ‘Yes’ to enable this module. Please make sure this feature is enabled in Google Analytics first before enabling in Magento2.
  • Enable Enhanced Conversion:- Set "Yes" to enable enhanced conversion to send PII data to Google Adwords to target actual customers. You need to turn on enhanced conversions in Google Adwords. Click here for more information
  • Product ID Attribute – Select the attribute which you have submitted in your Google base feed. For e.g. SKU
  • Brand Attribute – Please select brand attribute, if you have one otherwise put your brand name in the below input box.
  • Affiliation- Enter the affiliation name which you want to send with the GA4 data layers.
  • Use Base Currency - Set ‘Yes’ if you want to send base order data and ‘No’ to send store order data to Google. Set this ‘No’ only when you have multicurrency and you want to send different currency data to Google.
  • Product Price Include Tax- Set “Yes” then VAT will be included in the price.
  • Order Total Include VAT – Set “Yes” then VAT will be included in order total.
  • Always Send Parent SKU – Set “Yes” then it always send parent sku instead of child sku to GA during checkout.
  • Category Attribute- Please select category attribute if you have one otherwise put your brand name in the below input box. Attribute should be available for product listing 'Storefront Properties -> Used in Product Listing = Yes'
  • Is Category ID- Set "Yes" if "Category Attribute" is ID of the category, "No" if it is plain value
  • Send Parent Category – Set “Yes” to send the category path and Set “No” to send the category name only.
  • Default List- Enter the default list name if the product impression is not found
  • Send Admin Orders to Google– Select “Yes” to track orders created in admin
  • Source-Please add the Campaign Source for backend orders.
  • Medium-Please define the Campaign Medium for Backend Orders.
  • Send Product Impression on Scroll - Enable this feature when you have loads of products on product listing / category pages.
  • Category Ajax Enabled – Enable this feature if you have third party ajax enabled extension on your category page.

  • Add Carrier Title:- Use this to add carrier title to the shipping step. Set "Yes" to send carrier_code::carrier_title. Ex. flatrate::Flat Rate
  • Add Payment Title :- Use this to add payment method title to payment step. Set "Yes" to send method::title. Ex. checkmo::Check / Money Order
  • Steps Configuration:- define checkout steps
    • Step:- number of step
    • Selector:- add the selector for the step. Basic selector could be '#customer-email' this is equals to '#customer-email/change' and will send customer email itself
    • Type:- choose the step type from the dropdown

  • Enabled – Select “Yes” or “No” to enable or disable the module.
  • License Key – Please add the license for the extension which is provided in the order confirmation email. Please note license keys are site URL specific. If you require license keys for dev/staging sites then please email us at [email protected]
  • Account Id – Enter your Google Tag Manager Account Id.
  • Enable dynamic remarketing tags – Set “Yes” if you want to enable google dynamic remarketing tags to used for GTM.
  • Enable tracking for other sites – Set “Yes” to enable tracking for other sites.
  • Send Ecom Category Path – Set "yes" to send the category path with ecomm_category.
  • Enable GDPR Cookie Check – Select "Yes" or "No" to enable/disable GDPR Cookie Check
  • Force decline – If you set this to yes then GTM tracking will be turned off unless customer accepts the cookie policy from the cookie notification message from your website
  • GDPR Cookie Key – You can add name of your GDPR cookie here for our GDPR extension the name of cookie key is cookie_accepted but if you are using other GDPR extension then please check with extension developer
  • Enable UA data layer – Select "Yes" to add UA (Universal Analytics) events to the data layer.
  • Enable GA4 data layer-Select "Yes" to add GA4(Google Analytics 4) events to the data layer.

  • Enabled – Select “Yes” or “No” to enable or disable the module.
  • Configuration – Use this setting to create cookies by entering cookie parameter, cookie name, and cookie value.
  • Lifetime – Enter the lifetime of the cookie. It will be stored in the users browser as per the time defined in this setting.

The extension package contains JSONs which can be imported in GTM to set
up required Tags, Triggers and Variables. Go to the extension file m2-google-tag- manager-pro and then to the Data Folder (Path - m2-google-tag-manager-pro/data/) to find these files. The JSONs can be used to set up
  • Google Analytics 4
  • Enhanced Ecommerce Universal Analytics
  • Facebook Pixel
  • AdWords Dynamic Remarketing
  • Google Ads Conversion Tracking
  • Pinterest
  • Partnerize
  • Google Ads Enhanced Conversion Tracking
  • Primary Category Script (SetPrimaryCategories.php) – All of the above JSON files can be imported into GTM but primary category script needs to be added into the root directory of your website. Add the SetPrimaryCategories.php file in your website’s root directory and open the link as follows: - http://Your_website_URL.com/SetPrimaryCategories.php

To import JSONS provided with extension package follow below steps:
  • Log into GTM and navigate to your Account and container
  • In the top navigation, click through the Admin
  • Under the container options, click on Import Container
  • Choose the JSON file which you would like to import
  • Choose to either Overwrite or Merge
    • Overwriting the existing container will remove all your existing tags, triggers, and variables, and will replace them with those in the imported container. A new container version will be created before the import.
    • Merging containers will let you keep your existing tags, triggers, and variables, and just add in the new ones. If you choose to Merge the new container with your existing container, you’ll have to then decide whether you want to overwrite conflicting tags or rename conflicting tags.
  • Overwrite – If a variable, tag, or trigger in the new container has the same name but the contents are different, overwrite the old one with the new one.
  • Rename – If a variable, tag, or trigger in the new container has the same name but the contents are different, keep the old one and rename the new one.
  • Click Continue. You’ll see a preview of changes, showing how many tags, triggers, and variables will be added, modified, or deleted. You can also click the link to View Detailed Changes to see which tags, triggers, and variables are being added, modified, or deleted.
  • Once you’re satisfied with the changes, click Confirm.

Once the GTM container file has been imported, you need to change variable information with correct value corresponding to the site. To access variables, go to workspace where you have imported the JSONs and click on variables on left hand side navigation.
Variables Created with JSON’s
  • GA ID – This variable is created when GTM-UniversalAnalytics.json is imported and it holds value for Google Analytics Id for the site. Click on the GA ID and change it to correct value.
  • conversionID - This variable is created when GTM- AdwordsDynamicRemarketing.json is imported and it holds value for Google Adwords Conversion Id for the site. Click on the conversionID and change it to correct value.
  • facebookPixelID - This variable is created when GTM-Facebook.json is imported and it holds value for Facebook pixel Id for the site. Click on the facebookPixelID and change it to correct value.
  • currencyCode - This variable is created when GTM-Facebook.json is imported and it holds value for currency used on site. Click on the currencyCode and change it to correct value.

Once all set up is done and verified, need to Publish the tags to make it live on the website.
Step 1 − Click the SUBMIT button at the top right corner of the screen.
It will show the following screen.
Step 2 − Enter an identifiable Version name so that it can be easily understood for the changes made.
With the version description, you can be as elaborate as possible on the changes/additions of the tag in that version.
Step 3 − Scroll down to the Workspace Changes, you will see all the changes made in the tags, which are unpublished or in the PREVIEW mode.
Step 5 − Click PUBLISH and you will be presented with a summary for this version.

To turn on Enhanced E-commerce for a view, and label your checkout steps:
  1. 1.
    Click Admin at the top of any Analytics page.
  2. 2.
    Select the view for which you want to enable Enhanced E-commerce reporting.
  3. 3.
    In the view column, click E-commerce Settings.
  4. 4.
    Under Step 1, Enable E-commerce, set the status to ON.
  5. 5.
    Click Next Step.
  6. 6.
    Under Step 2, Enhanced Ecommerce Settings, set the status to ON. When you turn this option on
    • You can see the Enhanced E-commerce reports in the conversions section
    • The older, older category of E-commerce reports is no longer visible You can turn this option off to restore the older category of E-commerce reports.
  7. 7.
    Optionally, enter labels for the checkout steps that you have defined in your Magento steps configuration. Please see screenshots below for reference
Finally, Click Submit.

  • Go to Analytics and select the website on which you want to implement GA4 alongside universal analytics.
  • Once you are in universal analytics panel go into admin settings. Here you will notice an UPGRADE TO GA4 button, click on it. You will be walked with creating a new property. Follow along, once you are finished you will see the new GA4 view on your screen.
  • Now we need to setup the tag manager for GA4. If you have already imported all the tags using our JSON file then you only need to edit the tag and add your Measurement ID. However, if you are creating tags yourself then you need to create a new configuration tag.
  • To create a new configuration tag in GTM. Please look at the image below: -
  • To get the measurement id you need to go to your GA4 view. Go to the admin settings and then data streams. Click on the website url coloured in blue and a popup should open.
  • You will see the Measurement ID listed on the top right corner of this page.
  • Now for the final step import our Google Analytics 4 JSON file in your GTM to get all the configurations for GA4. Once done you will see data flowing into Google Analytics 4. Learn more about Google Analytics 4.

To enable enhanced conversions we first need to enable enhanced conversions in Google Adwords then complete the extension setup.

  1. 1.
    Sign in to your Google Ads account.
  2. 2.
    In the upper right corner of your account, click the tools icon , and under "Measurement," click Conversions.
  3. 3.
    Open the conversion action you want to use for setting up enhanced conversions.
  4. 4.
    In the “Enhanced conversions” section at the bottom, click Turn on enhanced conversions.
  5. 5.
    Select ”Google tag or Google Tag Manager” to set up enhanced conversions.
  6. 6.
    Click Agree to the compliance statement. By turning on enhanced conversions you confirm that you comply with our policies. The Google Ads Data Processing Terms apply to your use of enhanced conversions.
  7. 7.
    Click Check URL to check your website for a Google tag.
  8. 8.
    In “Tag type” you should be defaulted to Google Tag Manager if that is how you track conversions for this conversion action. Because you used Google Tag Manager to set up website tags, you need to use it to set up enhanced conversions. Follow the instructions below to set up enhanced conversions manually with Google Tag Manager.
  9. 9.
    Click Save.
Note: Once you have accepted the Terms of Service, it can take up to 5 days for your Google Tag Manager account to be enabled for enhanced conversions. Make sure your conversion tracking tag is set up in Google Tag Manager and then check back in 5 days to see the enhanced conversions functionality enabled. Please CLICK HERE for more details.

Go to Stores>Configuration>Scommerce Configuration>Tracking Base and set "Enable Enhanced Conversion" to "Yes". This will enable user data collection from the store which will be sent to Google Adwords as part of the the Enhanced Conversion.
Once done import the JSON file named "GTM-google_ads_enh anced_conversion_tracking.json" provided with the extension(data folder) in your GTM container . Change the 'conversion label' and 'conversion ID' in the "Google Ads Conversion Tracking" tag. Finally publish the changes to finish the setup.

It tracks orders placed from Admin > Sales > Orders > Create New Order.

Cookies from query Params configuration can be used to create new cookie parameters which can be stored in the users browser as per the valid time configured. for eg:- We have created a clickref cookie in the configuration. Now if the cookie parameter is passwed with the URL then that cookie will be created in the browser.
http://magento2.scommerce-mage.co.uk/?clickref=ab101 :- In this url we passed the cookie parameter "clickref" with the value "ab101". We can see this cookie being created in the below image:-

If you are using an older version of the extension(3.0.1 and below) where a common data layer is used to populate data to both UA and GA4 then upon updating to the latest version you need to make the following changes in GTM.

  • Google Analytics 4
  • GA4 Views/impressions of product/item details
  • GA4 View Item List Scroll
  • GA4 View Item List
  • GA4 Shipping info
  • GA4 Remove a product from a shopping cart
  • GA4 Refunds
  • GA4 Purchases
  • GA4 Promotion views/impressions
  • GA4 Promotion clicks
  • GA4 Product/Item List Clicks
  • GA4 Payment info
  • GA4 Begin Checkout
  • GA4 Add a product to a shopping cart

  • Ecommerce-detail-products
  • Ecommerce-product-detail-value
  • Ecommerce-checkout-products
  • Ecommerce-checkout-option
  • Ecommerce-remove-products
  • Ecommerce-refund-products
  • Purchase-affiliation
  • Purchase-tax
  • Purchase-shipping
  • ecommerce-promoView-promotions
  • ecommerce-promoClick-promotions
  • Ecommerce-click-products
  • ecommerce-product-click-list-name

  • View_item
  • View_item_list
  • Shipping Info
  • removeFromCart
  • Refund
  • Purchase
  • View_promotion
  • promotionClick
  • productClick
  • Payment_info
  • addToCart
Now follow the steps below to import the latest GA4 settings for GTM
Step 1:- Acquire the latest GA4 JSON file provided with the module.
Step 2:- Go to your GTM container then click on admin>Import Container.
Step 3:- Click on Choose container file and choose the JSON file acquired in step 1 then select the workspace new/existing. Also select Merge>Rename conflicting tags, triggers, and variables so that no crucial setting is lost.
Step 4:- Lastly, click confirm to finish the import. Once it's done you will have the latest tags, triggers and variables for GA4 in your GTM.

Go to Stores > Configuration > Scommerce > Google Tag Manager Pro. Scroll down to option Order Total Include Vat and toggle it to ‘No’. When turned ‘No’ the total order value data sent to Google analytics will not include VAT.

Go to Stores > Configuration > Scommerce > Google Tag Manager Pro. Scroll down to option Order Total Include Vat and toggle it to ‘Yes’. When turned ‘Yes’ the total order value data sent to Google analytics will also include VAT.

Go to Stores > Configuration > Scommerce > Google Tag Manager Pro. Scroll down to the option Always Send Parent SKU and toggle it to ‘No’. When turned ‘No’ if the customer selects a configurable product then the SKU data sent to Google analytics will be of the child product.

Go to Stores > Configuration > Scommerce > Google Tag Manager Pro. Scroll down to the option Always Send Parent SKU and toggle it to ‘Yes’. When turned ‘Yes’ if the customer selects a configurable product then only the SKU of the parent product will be sent to Google analytics.

Go to Stores > Configuration > Scommerce > Google Tag Manager Pro. Scroll down to the option Send Parent Category and toggle it to ‘Yes’. When turned ‘Yes’ if the customer selects a product then it will send the entire category path to the analytics if “No” then it will only send the category name.

Go to Catalog > Products and select any product. Then Scroll down to the option Primary Category.
Here you can set the primary category for any product. If you do not wish to send the assigned category to analytics, then you select which category path or name you want to send.
If you have a question related to this extension please check out our FAQ Section first. If you can't find the answer you are looking for then please contact [email protected].
Export as PDF
Copy link
On this page
Installation and User Guide for Magento 2 Google Tag Manager Pro Tracking Extension
Installation
Configuration Settings for Tracking Base
Configuration Settings for Google Tag Manager Pro
JSONs/Script provided with extension package
Importing JSONs into GTM
Setting variable information in GTM
Publishing Tags in GTM
Set up Enhanced Ecommerce in Google Analytics
Set up Google Analytics 4
Setup Enhanced Conversion
Back-end / Admin Tracking
Cookies From Query Params
Upgrading the Module From 3.0.1 and Below
Front-end Screenshots