Getting Started

Welcome to the Google Tag Manager documentation.

Whether you are a new or an advanced user, you can find some useful information here.

Go ahead, dive in!

Firstly, please, find our extension in My Downloadable Products section of our store. Learn how to install extension.

How to install the extension

How to install the extension using composer

  1. Backup your store's database and web directory.
  2. Login to the SSH console on your server and navigate to the root directory of the Magento 2 store.
  3. Copy the installation instructions from the page My Downloadable Products to the SSH console and press ENTER.

  4. Enable the extension:

        php -f bin/magento module:enable Mirasvit_Core Mirasvit_Tm Mirasvit_GoogleTagManager
  5. Install the extension:

        php -f bin/magento setup:upgrade
  6. Clean the cache

        php -f bin/magento cache:clean
  7. Deploy static view files
        rm -rf pub/static/*     
        rm -rf var/view_preprocessed/*  
        php -f bin/magento setup:static-content:deploy

How to install the extension manually

  1. Backup your store's database and web directory.
  2. Download archive from My Downloadable Products.
  3. Unzip the extension locally.
  4. Copy unzipped folder to the root directory of the Magento store.
  5. Enable the extension:

        php -f bin/magento module:enable Mirasvit_Core Mirasvit_Tm Mirasvit_GoogleTagManager
  6. Install the extension:

        php -f bin/magento setup:upgrade
  7. Clean the cache

        php -f bin/magento cache:clean
  8. Deploy static view files
        rm -rf pub/static/*     
        rm -rf var/view_preprocessed/*  
        php -f bin/magento setup:static-content:deploy

Install the extension for Hyva

  1. Run the command

        composer require mirasvit/module-gtm-hyva:*
  2. Enable installed Hyva modules:

        bin/magento module:enable Hyva_MirasvitGoogleTagManager
  3. Update Magento database schema and data with the command:

        bin/magento setup:upgrade
  4. Compile the code of the installed extension:

        bin/magento setup:di:compile
  5. Run the command below to clean the cache:
        bin/magento cache:flush

Quick Start

Our Google Tag Manager for Magento 2 is a simple, yet powerful extension that allows you to track the shopping behavior of your customers. Gathered data is supplied through the Google Tag Manager service (GTM) to any analytics suite to get hints on how to increase marketing ROI and boost sales.

Use this extension to track the shopping behavior of customers. Know when they add/remove/view cart, add to wishlist, begin checkout, make purchase, choose shipping and payment methods, and many other actions.

Configuration Settings

The module Google Tag Manager (GTM) for Magento 2 requires a prior configuration before it is fully ready to use.

In order to connect your Magento 2 store to the Google Tag Manager service using our extension, it is required that you create an account on the GTM service. A Google account is required to create a GTM account.

Setup Google Tag Manager

1. Get GTM code snippets

Login to your GTM account and navigate to Workspace section. Click your container ID (find a string GTM-XXXXXX) to open a window with <head> and <body> GTM code snippets.

image

Copy these GTM JavaScript code snippets.

image

2. Enable GTM

In your Magento store navigate to Store > Settings > Configuration > Mirasvit Extensions > Google Tag Manager to open the module's settings.

Set Enable GTM to yes.

Paste GTM code snippets:

  • Place <head> code snippet (formatted as <!--Google Tag Manager-->) into the script field
  • Fill no-script field with <body> code snippet (formatted as <!--Google Tag Manager (nocstipt)-->)

image

Replace GTM-XXXX with the ID of your Google Tag Manager account.

Activate Enable GTM Logging for extension to write logs and store them in the file var/log/gtm_all.log.

3. Configure the Container

To transfer data from GTM to analytics suite, you need to create GTM tags. You can do this manually in GTM service or use the Container Import section in your Magento store. This provides configuration for GA4, Google Universal Analytics, Google Ads Conversions

To configure a container provide data on:

image

image

image

Note

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

Configure Google Ads

Configure Google Ads by providing:

image

Admin Operations Tracking

image

  • Tracking Refund. Enable to track the return of goods
  • Tracking Admin Order. Enable to track orders created through admin.
  • GA API Secret. Paste here your GA API Secret.

    To add a GA API Secret:

  • Go to analytics.google.com. click Admin.
  • In the Property column, click Data Streams and open the data stream
  • Click Measurement Protocol API secrets
  • Here you can create a new API secret and give it an alias.
  • Now that your new API secret is created, be sure to copy the secret value.
  • Paste this value into the corresponding field in your admin

Attribute mapping

This section allows to configure data in the tracking events.

image

Option Description
Track Brand on the Category pages Enable it to track the relevant brand attribute on category pages.
Brand Select the corresponding brand attribute or leave it empty to disable brand tracking.
Track Variants Set Yes to activate product variants tracking.
Custom dimensions and metrics Add these to collect and analyze the attributes from your store which are not tracked automatically by our extension.

Customer mapping

Activate Customer Mapping option to track Group ID in your store.

image

Frontend debug panel

Google Tag Manager provides a debug panel on frontend to monitor the data collection. Activate by adding debug=gtm at the end of the page URL.

image

The debug panel allows you to see every tracked action made on the page and view which data was collected.

Tag Manager

Some of the extension's settings are now available on the Tag Manager tab of its settings page.

Option Description
Product identifier Set the attribute that will be used for product tracking. Select from ID, or SKU.
Identifier resolution Select a parent or child product to track..
Track view catalog page event Set Yes to track catalog pages.

How to upgrade extension

To upgrade the extension, follow these steps:

  1. Backup your store's database and web directory.
  2. Login to the SSH console of your server and navigate to the root directory of the Magento 2 store.
  3. Update the extension with all dependencies:

        composer require mirasvit/module-gtm:* --update-with-dependencies

    Note

    If you updated the module from the version below 2.0.0 you should enable the module Mirasvit_Tm

    Run ```shell php -f bin/magento module:enable Mirasvit_Tm

    
    <br><br>
    

    Note

    In some cases, the command above is not applicable, or it's not possible to update just the current module, or you need to upgrade all Mirasvit modules in a bundle. In this case, the command above will have no effect. <br><br> Run instead `composer update mirasvit/*` command. It will update all Mirasvit modules installed in your store. <br><br>
  4. Install the updates:

        php -f bin/magento setup:upgrade
  5. Clean the cache

        php -f bin/magento cache:clean
  6. Deploy static view files
        rm -rf pub/static/*     
        rm -rf var/view_preprocessed/*  
        php -f bin/magento setup:static-content:deploy

Disabling the Extension

Temporarily Disable

To temporarily disable the extension please follow these steps:

  1. Login to the SSH console on your server and navigate to the root directory of the Magento 2 store.
  2. Disable the extension:
        php -f bin/magento module:disable Mirasvit_GoogleTagManager
  3. Log in to the Magento backend and refresh the store cache (if enabled).

Extension Removal

To uninstall the extension, please follow these steps:

  1. Login to the SSH console on your server and navigate to the root directory of the Magento 2 store.
  2. Disable the extension:

        php -f bin/magento module:disable Mirasvit_GoogleTagManager
  3. Remove the extension:
        composer remove mirasvit/module-gtm
  4. Log in to the Magento backend and refresh the store cache (if enabled).

2.0.23

(2024-10-30)

Fixed

  • Compatibility with Tiktok Pixel

2.0.22

(2024-07-12)

Fixed

  • Search tracked twice

2.0.21

(2024-07-12)

Improvements

  • Added new events 'search' & 'sign_up'

2.0.20

(2024-07-10)

Fixed

  • InvalidArgumentException: Either remote URL or hashable content is required when CSP AND GTM are enabled but GTM "GTM Regular Code" setting is empty

2.0.19

(2024-07-02)

Fixed

  • add_to_cart fire after view_cart if magento setting "After Adding a Product Redirect to Shopping Cart" is enabled

2.0.18

(2024-07-02)

Improvements

  • Compatibility with CSP
  • Compatibility with Aheadworks_OneStepCheckout

Fixed

  • Compatibility with M2.3
  • Cannot read properties of undefined reading length for out of stock configurable products

2.0.17

(2024-06-07)

Improvements

  • Added source and medium parameters to the admin order tracking

2.0.16

(2024-06-05)

Improvements

  • Refactor

2.0.14

(2024-05-27)

Improvements

  • Custom Dimensions added to the admin orders: utm_source,utm_medium

2.0.13

(2024-05-17)

Fixed

  • customerId must be of type int, null given when track backend orders
  • Added setting for Catalog Brand tracking

2.0.12

(2024-05-10)

Improvements

  • Added server side tracking for admin orders
  • Moved Track view catalog page event to TM vodule

2.0.11

(2024-04-26)

Fixed

  • Product custom options prices were not added to the item prices for cart/checkout events

2.0.10

(2024-04-05)

Fixed

  • Track brand for child items
  • Product prices are tracked without included option prices in cart/checkout

2.0.9

(2024-04-01)

Fixed

  • AddToCart track was not fired in hyva

2.0.8

(2024-03-28)

Fixed

  • Unicode was removed from the items.item_brand

Improvements

  • Added user data variables to the Purchase event(enhanced_conversion_data)

2.0.7

(2024-03-19)

Fixed

  • Custom product attributes return questionmarks for some locales
  • User properties pushed to ga via dataLayer for add_to_cart, shipping and payment events

Improvements

  • Track preselected product variant
  • Track user email for the Guest conversions

2.0.6

(2024-03-01)

Improvements

  • Google Consent v2 compatibility

2.0.4

(2023-12-27)

Fixed

  • Ability to track refunds per storeview

2.0.3

(2023-11-28)

Fixed

  • Tracking coupon name in the "add_shipping_info" event

2.0.2

(2023-11-22)

Fixed

  • Duplicate event "add_to_cart"

2.0.1

(2023-10-25)

Fixed

  • track_variants config doesn't work

2.0.0

(2023-10-17)

Improvements

  • The Facebook Pixel is placed in a separate module

1.2.61

(2023-10-12)

Fixed

  • Prices are not tracked for the configurable products

1.2.60

(2023-08-24)

Fixed

  • Events tracked the final product price instead of the original price

Improvements

  • Added price and special_price item values to the "Custom dimensions and metrics"

1.2.59

(2023-08-18)

Fixed

  • str_replace(): Argument #3 ($subject) must be of type array|string, Magento\Framework\Phrase given
  • Compatibility with ajax checkout(prevent double tracking of payment and shipping events)

Improvements

  • Slightly improved logging format
  • Remove GA3 support
  • Speeding up the collection of product attributes

1.2.58

(2023-07-13)

Fixed

  • Attribute mapping for categories

1.2.57

(2023-07-06)

Fixed

  • Conflict with Amasty GDPR

1.2.56

(2023-06-21)

Fixed

  • Tracking of product discount

1.2.55

(2023-06-19)

Fixed

  • Missed value and currency values for view_item event

1.2.54

(2023-06-07)

Fixed

  • Issue when Pixel code replace GTM code

1.2.53

(2023-06-01)

Improvements

  • Added ability to track refunds

Fixed

  • Download tag settings files for websites

1.2.52

(2023-05-23)

Fixed

  • Encoding for the non alphabetical characters

develop

1.2.51

(2023-04-20)

Fixed

  • Wrong GTM code load when the option "Move JS code to the bottom of the page" is enabled

1.2.50

(2023-04-14)

Fixed

  • Product Qty for the "view_item" event

Improvements

  • Added store variables to Custom dimensions and metrics

1.2.49

(2023-03-23)

Fixed

  • JS error "TypeError: Cannot read properties of undefined"

1.2.48

(2023-03-01)

Fixed

  • Tracking of the customer group
  • Mapping value for the attribute "Product SKU"

Improvements

  • Compatibility with MageBig_QuickView and Ajaxcartpro

1.2.47

(2023-02-13)

Fixed

  • Type of tax and shipping values in the purchase event

Improvements

  • Added order subtotal to the Attribute mapping

1.2.46

(2023-01-23)

Fixed

  • Tracking of the event "add_to_cart"

1.2.45

(2022-12-26)

Improvements

  • Added order attributes to the purchase event

1.2.44

(2022-12-07)

Fixed

  • Discount value
  • Remove unnecessary field "product_id"

Improvements

  • Added "Dynamic remarketing with Google Analytics" tracking

1.2.43

(2022-12-05)

Fixed

  • Set 'product_group' content_type for the configurable products and category view pages

1.2.42

(2022-11-29)

Fixed

  • The issue when tax does not count in the event "add_payment_info"

1.2.41

(2022-11-17)

Fixed

  • Empty value for the Region Code dimension
  • Return brand label instead of value

1.2.40

(2022-11-08)

Fixed

  • Compatibility with php7.1

1.2.39

(2022-11-01)

Improvements

  • Compatibility with Plumrocket AMP extension

Fixed

  • Tracking variants in GA3

1.2.37

(2022-10-31)

Improvements

  • Added param "new_customer" to "purchase" event

1.2.36

(2022-10-04)

Fixed

  • Tracking of a product attributes

Improvements

  • Tracking of the selected shiping method

1.2.35

(2022-09-30)

Fixed

  • Payment method does not track for GA4 when FB Pixel enabled

1.2.34

(2022-09-20)

Fixed

  • Double purchase event for pixel

1.2.33

(2022-09-16)

Fixed

  • Product qty for product view event

1.2.32

(2022-09-15)

Fixed

  • List name and position for GA3 event "view_item_list"

1.2.31

(2022-09-12)

Fixed

  • Notice: Undefined variable: contentIds in GoogleTagManager/Converter/PixelConverter.php

1.2.30

(2022-09-06)

Fixed

  • Added content_type, id & content_ids parameters
  • Event "set_user_properties" not fire

1.2.29

(2022-09-01)

Fixed

  • Remove Item events for GraphQL

1.2.28

(2022-09-01)

Improvements

  • Added add_payment_info and add_shipping_info to GA4 container configuration

1.2.27

(2022-08-11)

Fixed

  • UA tracking category

1.2.26

(2022-08-04)

Improvements

  • Compatibility with Swissuplabs page speed optimizer
  • Added option "Track view catalog page event"

1.2.25

(2022-07-21)

Improvements

  • Added domains to the csp whitelist

Fixed

  • Call to undefined method Magento\Catalog\Model\Product\Type\Simple\Interceptor::getUsedProducts()

1.2.24

(2022-07-21)

Improvements

  • Tracking product variants for swatches

1.2.23

(2022-07-14)

Fixed

  • Category data for cart events
  • Disable GTM output for AMP pages

1.2.22

(2022-07-05)

Fixed

  • Track base price instead of store price

1.2.21

(2022-06-23)

Improvements

  • Added dimension "Attribute Set" for product
  • Added ability to log gtm data

1.2.20

(2022-06-20)

Fixed

  • Tracking product variants in the cart

1.2.19

(2022-06-06)

Fixed

  • Error "TypeError: Mirasvit\GoogleTagManager\Converter\DataConverter::getProductBrand(): Return value must be of type string, null returned"

1.2.18

(2022-05-26)

Fixed

  • Changed base price to cart price

1.2.17

(2022-05-11)

Fixed

  • Error "Notice: Undefined index: gtm_id"

1.2.16

(2022-05-09)

Improvements

  • Tracking of the "add to cart" event

1.2.15

(2022-05-03)

Fixed

  • Compatibility with Klarna Checkout

1.2.14

(2022-04-29)

Fixed

  • CSP rules

1.2.13

(2022-04-25)

Fixed

  • Settings scope

1.2.12

(2022-04-21)

Fixed

  • product/variant id resolution

1.2.11

(2022-04-20)

Improvements

  • Added customer/address attributes (from the map) to the purchase event

1.2.10

(2022-04-20)

Fixed

  • Change scope for import config

1.2.9

(2022-03-25)

Fixed

  • Checkout Behavior tracking

1.2.8

(2022-03-15)

Fixed

  • Issue with bundle products

1.2.7

(2022-03-14)

Fixed

  • issue with remove cart event

1.2.6

(2022-01-19)

Improvement

  • Added Conversion and Remarketing tags to the import

1.2.5

(2021-12-29)

Fixed

  • Settings for the Google Ads

Improvement

  • Added Customer attribute to the dimensions

1.2.4

(2021-12-06)

Fixed

  • Error "Return value of ConfigProvider::getConversionId() must be of the type string, null returned"

1.2.3

(2021-12-03)

Fixed

  • Disable the GTM in the backend

Improvement

  • Added Google Ads conversion event

1.2.2

(2021-11-30)

Fixed

  • Event for Universal Analytics(GA3)

1.2.1

(2021-11-23)

Improvement

  • Added setting files for GTM

1.2.0

(2021-11-19)

Fixed

  • Removed config "Measurement IDs". Added "GTM Regular Code"

1.1.0

(2021-11-15)

Improve

  • Removed config "GTM Regular Code". Added "Measurement IDs"

Fixed

  • Error "Notice: Array to string conversion in vendor/mirasvit/module-gtm/src/GoogleTagManager/Converter/DataConverter.php on line 127"

1.0.2

(2021-11-09)

Improvement

  • Added Facebook Pixel analytics

1.0.1

(2021-07-12)

Features

  • Initial release