Magento 2 Google Global Site Tag (gtag.js) with GA4(Google Analytics 4) Enabled

Installation and User Guide for Magento 2 Global Site Tag (gtag.js) Extension

Table of Contents

  1. Installation
    • Installation via app/code
    • Installation via Composer
    • Installation via Composer( (Hyvä Theme):
  2. Configuration Settings for Tracking Base
    • General Settings
    • Checkout Behaviour
  3. Configuration Settings for Global Site Tag (gtag.js)
    • General Settings
  4. Set up Google Analytics 4
  5. Set Up Cross Domain Measurement
  6. Front-end Site view
    • Home Page with Tags
    • Gtag.js Code
    • Gtag.js Brand Name

Installation

php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy

https://docs.scommerce-mage.com/magento-2-extensions/installation-via-composer/installation-via-composer

composer require hyva-themes/magento2-scommerce-gtag

Configuration Settings for Tracking Base

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

General Settings

gtag_config_1.png

image.png

image (1).png


Checkout Behaviour

image (2).png

Configuration Settings for Global Site Tag (gtag.js)

Go to Admin > Stores > Configuration > Scommerce Configuration > Global Site Tag (gtag.js)

General Settings

image (3).png

image (4).png

Set up Google Analytics 4

image.jpg

Set Up Cross Domain Measurement

Step 1:- Go to Google Analytics 4 Admin>Data Streams>Select your stream>Configure Tag Settings >Configure Your Domains, here add your domains or subdomains that you want to track.

image (5).png

Step 2:- Add the all domains added above in the configuration "Domains to link" comma separated. Now if you have any links taking you from your main site to the linked site, _gl cookie is automatically apended to the URL that contains several information such as source website, source campaign etc hereby accomplishing the cross domain measurement. an example of such URL is as follows:

https://magento2demo.scommerce-mage.co.uk/?_gl=1fzl3bd_gaMTk3ODY0NTU1Mi4xNzIyODQzNDc3_ga_FWXJFY956H*MTcyMjg1OTYxOC40LjEuMTcyMjg1OTYzNS4wLjAuMA..

Front-end Site view

image (1) (1).png

image (2) (1).png

image (1).jpg

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 support@scommerce-mage.com.


Revision #14
Created 28 April 2025 12:40:10 by Admin
Updated 24 October 2025 09:17:13 by scommerce