Sidebar

magento_2:google_analytics_4_with_gtm_support

For more details, see how the Google Analytics 4 with GTM Support for Magento 2 extension works.

Guide for Google Analytics 4 with GTM Support for Magento 2

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.

  • Track product impressions & clicks
  • Observe shopping cart & checkout events
  • Monitor customer account events
  • Discover promotions performance
  • Generate JSON file with a single click
  • Server-Side and Client-Side tracking
  • Track Google AdWords conversions

GTM API Configuration

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.

GTM Tags require some time for activation. Typically it takes 24-48 hours before the GTM tag will start sending data to your Google Analytics account.

General Configuration

Before starting with the extension, make sure that Adobe Commerce Google Analytics feature is disabled.

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.

What is the difference between Client-side tagging and Server-side tagging?

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.

Google AdWords Conversion

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.

How to find Conversion ID and Conversion Label?
  • Sign in to your Google Ads account
  • In your Google Ads account, click the Tools and Settings menu.
  • Select Measurement: Conversions, which opens to the Conversion Actions table.
  • Select the name of the conversion that you want to use from the Conversion action column.
  • Expand the tab for Tag setup to view the tag details.
  • Select Use Google Tag Manager.
  • Copy the Conversion ID and Conversion Label.

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.

Note: access to this feature will be enabled once you update the module Cookie Consent (GDPR) to the version, 2.10.1 or newer.

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.

Json Export Options

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.

Make sure your settings changes are saved to download the updated data file.

Import Container

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.

List of tracking events:

  • login - is triggered when a user logs into their account.
  • sign_up - is triggered when a user creates an account.
  • add_payment_info - is triggered whenever a user adds their payment information.
  • add_shipping_info - is triggered whenever a user adds their address information on the Checkout Page.
  • add_to_cart - is triggered whenever a user adds a product to their cart, or when they add to the quantity of a product that's already within their cart.
  • add_to_wishlist - is triggered whenever a user adds a product into their wishlist.
  • begin_checkout - is triggered whenever a user proceeds to the Checkout Page.
  • purchase - is triggered when a user has placed an order and is redirected to the Success Page.
  • remove_from_cart - is triggered whenever a user removes a product from their cart, or when they subtract from the quantity of a product that's already within their cart.
  • select_item - is triggered when a user clicks on a product contained within a list, such as on your Category Page or a Product Carousel.
  • select_promotion - is triggered when a user clicks on a link contained within a block, banner or piece of content tagged as a Promotion.
  • view_cart - is triggered when a user navigates to the Cart Page.
  • view_item - is triggered when users open up and view one of your Product Pages.
  • view_item_list - is triggered when a user views a list of items, such as your Category Page, or a Product Carousel.
  • view_promotion - is triggered when a user views a block, banner or piece of content tagged as a Promotion.

Find out how to install the Google Analytics 4 with GTM Support extension for Magento 2 via Composer.
Rate the user guide
 stars  from 1 votes (Details)
magento_2/google_analytics_4_with_gtm_support.txt · Last modified: 2023/08/15 14:33 by asemenova