LogoLogo
  • Magento 2 Extensions
    • SEO Extensions
      • Magento 2 Canonical Urls for Category, Product, CMS, and Other pages
      • Magento 2 Advanced SEO Suite
      • Magento 2 Cross Linking SEO
      • Magento 2 Google Page Speed Optimizer
      • Magento 2 Google Site Map Exclusion
      • Magento 2 Alternate Hreflang Tags
      • Magento 2 Google Rich Snippets
      • Magento 2 SEO Unique Catalog URLs
    • Site Speed Extensions
      • Magento 2 Full Page Cache Warmer
      • Magento 2 Google Page Speed Optimizer
      • Magento 2 Image Optimizer
      • Magento 2 AJAX Infinite Scroll
      • Magento 2 Lazy Load Image
    • Marketing Extensions
      • Magento 2 How Did You Hear About Us
      • Magento 2 Free Shipping Bar
      • Magento 2 Product Scheduler
      • Magento 2 Apply Discount coupon Code Via Link
      • Magento 2 Dynamic Sale Catagory
      • Magento 2 Facebook Conversion and Audience Pixel Tracking
      • Magento 2 Google Dynamic Remarketing Tag
      • Magento 2 Perfect Audience Tracking
      • Magento 2 Product Feed
      • Magento 2 Cash Back Discount
      • Magento 2 Competition or Prize Draw with Social Booster
      • Magento2 Custom Options Discount
      • Magento 2 Product Label
    • Analytics & Tracking Extensions
      • Magento 2 Google Global Site Tag (gtag.js) with GA4(Google Analytics 4) Enabled
      • Magento 2 Google Enhanced Ecommerce Tracking
      • Magento 2 Google Tag Manager (GTM) GA4 Ecommerce Tracking
      • Magento 2 Google Tag Manager Tracking
      • Magento 2 missing orders or transactions in Google Analytics (GA)
      • Magento 2 Consent mode's setup guide
    • Payment and Shipping Extensions
      • Magento 2 Delivery Instructions and Delivery Date
      • Magento 2 Product Handling or Additional Fee
      • Magento 2 Surcharge or Additional Fee
      • Magento 2 Shipping Carrier Tracker
    • User Experience Extensions
      • Magento 2 How Did You Hear About Us
      • Magento 2 FAQ
      • Magento 2 Subcategory Grid/List Extension
      • Magento 2 Ajax Login and Add to Wishlist
      • Magento 2 Custom Stock Status Extension
      • Magento 2 Product Shelf Life
      • Magento 2 VAT Exemption
      • Magento 2 Cancel Order by Customer on the Frontend
      • Magento 2 Lazy Load Image
      • Magento 2 AJAX Infinite Scroll
      • Magento 2 Previously Ordered Products
      • Magento 2 Social Login
      • Magento 2 Substitute Products
      • Magento 2 Product 360 view
      • Magento 2 Product Reviews
    • Admin Extensions
      • Magento 2 Update Order Email Address
      • Magento 2 Admin Action Log
      • Magento 2 Ajax Login and Add to Wishlist
      • Magento 2 Custom Stock Status Extension
      • Magento 2 Product Shelf Life
      • Magento 2 Repeat Order
      • Magento 2 Associated or Linked Product Stock Update
      • Magento 2 VAT Exemption
      • Magento 2 Order Delete or Archive
      • Magento 2 Order Tagger
      • Magento 2 Subcategory Grid/List Extension
      • Magento 2 Advanced Reporting Extension
      • Magento 2 Export Custom Product Attribute
      • Magento 2 Advanced Admin Login Security
      • Magento 2 Admin Security Checklist
      • Magento 2 Security Suite
      • Magento 2 AI Content Generator
      • Magento 2 Content Security Policy (CSP) Whitelist Manager
      • Magento 2 OTP Login
      • Magento 2 Admin Account Switcher
    • Data & Privacy Extensions
      • Magento 2 Not On The High Street Integration
      • Magento 2 GDPR Compliance: Anonymisation of order data
      • Magento 2 Antispam Extension
    • Integration Extensions
      • Magento 2 Diamond Search
      • Magento 2 Not On The High Street Integration
      • Magento 2 Creditsafe Integration
    • Installation Via Composer
  • Magento 1 Extension
    • SEO Extensions
      • Magento SEO Unique Catalog URLs
      • Jquery Asynchronous Image Loader (JAIL)
      • Magento Image Optimizer
      • Canonical Urls for Category, Product and CMS pages
      • Google Site Map Exclusion with Image sitemap
      • Google Friendly SEO Layered Navigation
      • Magento Rich Snippets & Cards (schema.org)
      • Meta Information for Any Page
    • Marketing Extensions
      • Where Did You Hear About Us?
      • Google Tag Manager Tracking
      • Google AdWords Conversion Tracking
      • Order Follow Up or Review Booster
      • Competition or Prize Draw Module with Social Booster
      • Apply Discount Coupon Code via Link
      • Abandoned Basket Email Alert
      • Cash Back Discount
      • Dynamic Sale Category
    • Analytics & Tracking Extensions
      • Google AdWords Conversion Tracking
      • Google Adwords Dynamic Remarketing Tag
      • Facebook Conversion and Audience Pixel Tracking
      • Perfect Audience Tracking
      • Google Enhanced Ecommerce Tracking
      • Magento 1 / OpenMage GA4 Google Tag Manager (GTM)
      • Magento 1 Google Global Site Tag (gtag.js)
      • Magento 1 Consent mode's setup guide
      • Magento 1 Google Analytics Synchronization Extension
    • Payment and Shipping Extensions
      • Magento Delivery Instructions or Order Comments
      • Surcharge or Additional Fee
      • Magento Surcharge or Additional Fee on Payment Method or Countries
    • User Experience Extensions
      • Product Image Resize
      • Magento Delivery Instructions or Order Comments
      • Single Product Category Redirect
      • Testimonials
    • Admin Extensions
      • Admin Order Email
      • Magento Update Order Email Address
      • Product Review Administrator Notification Email
      • Automated Product Publish Date
      • Order Follow Up or Review Booster
      • Custom Variables Anywhere
      • Testimonials
    • Data & Privacy Extensions
      • EU Cookie Notification
      • Magento 1 GDPR Compliance: Anonymisation of order data
    • Site Speed Extensions
      • Product Image Resize
      • Jquery Asynchronous Image Loader (JAIL)
      • Magento Image Optimizer
Powered by GitBook
On this page
  • Installation and User Guide for Magento 2 Global Site Tag (gtag.js) Extension
  • Installation
  • Configuration Settings for Tracking Base
  • Configuration Settings for Global Site Tag (gtag.js)
  • Set up Google Analytics 4
  • Set Up Cross Domain Measurement
  • Front-end Site view

Was this helpful?

Export as PDF
  1. Magento 2 Extensions
  2. Analytics & Tracking Extensions

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

PreviousAnalytics & Tracking ExtensionsNextMagento 2 Google Enhanced Ecommerce Tracking

Last updated 8 months ago

Was this helpful?

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

Table of Contents

    • Installation via app/code

    • Installation via Composer

    • Installation via Composer(Hyvä Theme)

    • General Settings

    • Checkout Behaviour

    • General Settings

    • Home Page with Tags

    • Gtag.js Code

    • Gtag.js Brand Name

Installation

  • 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.

  • Installation via Composer(Hyvä Theme): Go to My Account section then go to Composer Instructions. Run the composer config commands mentioned on the page then run the below command to install the module on hyva theme.

composer require hyva-themes/magento2-scommerce-gtag

Configuration Settings for Tracking Base

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

General Settings

  • 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.

  • 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.

  • 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.

Checkout Behaviour

  • 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

Configuration Settings for Global Site Tag (gtag.js)

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

General Settings

  • Enabled – Select “Yes” or “No” to enable or disable the module.

  • Accounts ID – You can add multiple account id, it can be Analytics, Adwords.

    • Main Account – Select ‘Yes’ to set your main analytics id as an account id. This account will be used to connect gtag.js.

    • Use Linker – If this is enabled (set to ‘Yes’) then this account will be linked to domains from “Domains to link” field, which is specified below

    • Action – You can delete your account\, if required.

  • Enable Linker - If this is enabled then you can set linker properties, in domain configurations which is specified below e.g. Domain to link, Decorate Forms. This setting is mainly for Cross domain mesurement, so to use this you must first enable it in Google Analytics 4 Admin.

  • Domains to Link - Enter the domains that you want to link. Example destination.com, dest3.com or /^example.(com|de|nl)$/.

  • Decorate Forms - If you have forms on site pointing to the destination domain, set this property of the linker parameter to Yes

  • Promotion Tracking – Here is the format to set up the promotion tracking: <a href="#" data-promotion="CREATIVENAME" data-id="PROMOID" data-name="PROMONAME" data-creative="PROMOCREATIVE" data-position="PROMOPOSITION"> Content </a>

  • Enable Dynamic Remarketing Tag – If set to ‘Yes’, then this will enable and install remarketing tag to different pages.

Set up Google Analytics 4

  • Go to Analytics and select the website on which you want to implement GA4.

  • 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

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.

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=1*fzl3bd*_ga*MTk3ODY0NTU1Mi4xNzIyODQzNDc3*_ga_FWXJFY956H*MTcyMjg1OTYxOC40LjEuMTcyMjg1OTYzNS4wLjAuMA..

Front-end Site view

  • Home Page with Tags - In Tag Assistant tool you can see all the fired tags.

  • Gtag.js Code - In the below image you can see the UA and AW tracking id’s from Admin > Stores > Configuration > Scommerce Configuration > Global Site Tag (gtag.js) > Account Id > Click on “Add Account” – G-R6FSTDG16K, AW-123234123.

  • Gtag.js Brand Name – You can add brand name from Admin > Stores > Configuration > Scommerce Configuration > Global Site Tag (gtag.js) > Brand Name – “TestScommerce”.

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 .

Enable Tracking for Other Sites – This will enable other sites variables ( instead of retail site variables.

If you have a question related to this extension please check out our first. If you can't find the answer you are looking for then please contact .

Installation Via Composer
support@scommerce-mage.com
https://support.google.com/tagmanager/answer/6106009?hl=en-GB#zippy=%2Ccustom
)
Installation
Configuration Settings for Tracking Base
Configuration Settings for Global Site Tag (gtag.js)
Set up Google Analytics 4
Set Up Cross Domain Measurement
Front-end Site view
support@scommerce-mage.com
FAQ Section