For more details, see how the Google Analytics 4 with GTM Support for Magento 2 extension works.
Smoothly integrate your store with Google Analytics 4. Get access to a variety of built-in events and extended performance reports. Gain valuable insights into every stage of customer journey to make informed business decisions.
Before starting to work with the extension you should connect your store with Tag Manager and Google Analytics. You can do it by filing in the appropriate credentials in the following fields in the Stores → Configuration → Amasty Extensions → Google Analytics 4 with GTM:
Tag Manager Account ID - paste Account ID from your GTM account. Refer this documentation to explore how to create the account in GTM if you don’t have one.
To find the Account ID, please open the list of created accounts on this page: https://tagmanager.google.com/#/home. Choose the account you need and go to its settings.
In the window that opens you can see the Account ID in the top:
Tag Manager Container ID - paste Container ID from your GTM account. To do this, please find 8 digits of Container ID in the browser URL of Google Tag Manager, which looks like:
Measurement ID - paste Measurement ID from your GTM account. You can find it under your Google Analytics account: GA account > Admin > Data Streams > Select needed stream > Measurement ID.
You can refer this documentation to explore more about the Data Streams in Google Analytics 4.
Enable GA4 - select 'Yes' to enable the extension.
GTM Web Container ID - here you should paste the Public ID from your GTM account in order to start generating tags, triggers, and variables for GA4. You can copy your Public ID from here:
Product Identifier - specify how to identify products in GA4 and GTM either by SKU or by product ID from your Magento catalog
Enable Brand - set to ‘Yes’ to enable brand tracking.
Product Brand Attribute - select the corresponding brand attribute or leave it empty to disable brand tracking. This setting includes all product attributes and allows the store owner to choose identified attributes for the product’s brand.
Enable Variant - set to ‘Yes’ to activate product variants tracking.
Parent or Child Identifier - select a child / parent product to track on the cart, checkout, and success pages.
Order Success Page Total Calculation - calculates total amount on success page based on Subtotal or Grand Total.
Exclude Tax From Transaction - specify whether to exclude or not the tax amount from transactions.
Exclude Shipping From Transaction - specify whether to exclude or not the shipping amount from transactions.
Exclude Orders with 0 Grand Total - set to ‘Yes’ to exclude orders with 0.00 value from purchase transactions.
Success Page Paths - in case you have a custom checkout and the path of the success page differs from the default Magento path of 'checkout/onepage/success', you can mention the custom path here to ensure that the transaction data is sent to GTM.
Measure Product Clicks - enable this option to track clicks on products from Category Pages, Search Results Pages, and blocks of Related/Cross-Sell/Up-Sell products.
Promotion Tracking - set to ‘Yes’ to enable promotion tracking.
Promotion Tracking code example:
<a href="#" data-promotion-event data-promotion-id="PROMOID" data-promotion-name="PROMONAME" data-promotion-creative-name="PROMOCREATIVE" data-promotion-creative-slot="PROMOSLOT" >Content</a>
To track the promotion events for the particular block, add the promotion tracking code to the main/root tag of this block.
GTM Server Container URL - the extension supports both Client-side tagging and Server-side tagging. Client-site tagging is used by default. Therefore if you want to continue using this type of tagging, just leave this field empty. But if you want to use server-site tagging, you should enter a subdomain for your server container in this field. Please follow the link to configure this possibility.
In client-side tagging, a single container resides on the website or app. The container holds all tags, triggers, variables, and related code used to measure user interactions. When a user visits a page, the container is activated and loads the related tags. When the user performs an action that triggers a tag, the event data gets dispatched into one or more HTTP requests from the browser or device to your Google products or advertising partners.
Server-side tagging uses two containers: Web container that resides on the website or app and server container that resides in a cloud environment. The web container hosts only the tags necessary to monitor and dispatch information about user interactions and generate events as HTTP requests. The server container accepts all HTTP requests from the web container. In the server container, you can set up processing rules before sending data to your Google products or third-party endpoints.
Refer this documentation for more information.
Enable - set to 'Yes' to enable functionality of Google Adwords conversions tracking.
Google Conversion ID - paste the Google Conversion ID from your Google Ads account.
Google Conversion Label - paste the Google Conversion Label from your Google Ads account.
Find more information in Google documentation.
Google Conversion Currency Code - enter the currency used in AdWords account. For example: USD, EUR, etc.
Exclude Orders with 0 Grand Total - set to 'Yes' to exclude orders with 0 Grand Total so that they don't affect the conversion.
The extension is compatible with Amasty Cookie Consent extension, which means that it is possible to send data to GA4 using conversion modeling and behavior modeling if the user declined cookies.
If you have Magento 2 Cookie Consent (GDPR) module installed, the following section in the Google Analytics 4 extension configuration will become available:
Enable - select 'Yes' to enable Google consent mode to send data to GA4 using conversion modeling and behavior modeling if the user declined cookies.
Consent Types - specify the needed consent types and their settings. You can find more information about Tag Manager consent types here.
To transfer data from GTM to the analytics suite, you need to create GTM tags. You can do this manually in GTM service or use the Json Export Options section in your Magento store. This provides configuration for GA4.
Firsty you need to generate and export the file.
Click the button Generate and Download Json for Variables, Triggers and Tags in the extension configuration settings. After that, you can upload that file to Google Tag Manager to create and import Tags, Triggers, Variables.
To import the container, navigate to your Google Tag Manager Dashboard, access the Admin section and choose the Import Container section.
Click on the Choose container file button and upload your previously generated and downloaded JSON file here. Then, choose a workspace (you can choose an existing workspace or create a new one) and an import option.
After importing the generated JSON, a preview will show up letting you know the number of changes made to the container. There should be Tags, Triggers and Variables created or updated in various amounts depending on your Magento Admin settings. Click Confirm and the settings import is complete.
Once all your tags have been imported into Google Tag Manager, return to your GTM account and click Publish/Submit at the top of the page. If the container is not published or submitted in your GTM account, no tracking will be available.
You can also refer to this documentation to explore more about Container Import in Google Tag Manager.
To check if all needed events were imported successfully, go to your Google Analytics account and see available events in Engagement reports or Real Time reports. But please consider that it may take 30 minutes to 48 hours for statistics to appear in your Google Analytics account based on the tracked data, according to the GTM documentation. However, real-time data should be visible right away if your account is set up correctly.