# yireo/magento2-googletagmanager2

> Add Google Tag Manager to Magento

`composer require yireo/magento2-googletagmanager2`

Canonical URL: https://packagento.com/yireo/magento2-googletagmanager2

## At a glance

- **Vendor**: yireo (https://packagento.com/yireo.md)
- **Latest version**: 3.10.7 — released 2026-02-24
- **Pricing**: Free
- **Package type**: Magento 2 module
- **Status**: active, accepting new buyers

## Installation

Packagento is licence-gated, so even free packages need a licence on a project before Composer can resolve them.

1. **Sign in or create an account** at https://packagento.com/customer/account/.

2. **Add the package to your account.** Open https://packagento.com/yireo/magento2-googletagmanager2 and complete the free checkout. A licence is minted automatically.

3. **Create or pick a project, then activate the licence on it.**
   - Projects represent the Magento installs you deploy to. Manage them at https://packagento.com/projects/.
   - Activate the new licence on the project you'll deploy this package to. Activation is what generates the Composer credentials scoped to that project.

4. **Add the project credentials to your Magento codebase.**

   Grab the project's public + private key from https://packagento.com/projects/ (open the project, then its Credentials tab), and add them to `auth.json`:

   ```json
   {
     "http-basic": {
       "packagento.com": {
         "username": "ppk_live_...",
         "password": "psk_live_..."
       }
     }
   }
   ```

   Add the Packagento Composer repository to `composer.json`:

   ```json
   {
     "repositories": [
       { "type": "composer", "url": "https://packagento.com" }
     ]
   }
   ```

5. **Install and apply.**

   ```bash
   composer require yireo/magento2-googletagmanager2:*
   bin/magento setup:upgrade
   bin/magento setup:di:compile
   bin/magento cache:flush
   ```

## What it does

Add Google Tag Manager to Magento

## README

**A client-side implementation of Google Tag Manager for Magento 2**

**Also see: https://www.yireo.com/software/magento-extensions/googletagmanager2**

**Currently, the `Yireo_GoogleTagManager2` module has been refactored heavily: The architecture is redesigned, GA4
support is being added, GA3 support (aka UA/EE) is being removed, click-events are added and overall there is a huge
extensibility being added. The refactoring has come available under a new major version 3. If you were not using this
extension yet, you can just proceed with the composer installation which will pick this new version. If you were
using major version 2 in the past, edit your `composer.json` file manually to use the new version `^3.0`. Alternatively, update your `composer.json` by using the command `composer require yireo/magento2-googletagmanager2:^3.0 --no-update`. Next, upgrade with `composer update`.**

[![Latest Stable Version](https://poser.pugx.org/yireo/magento2-googletagmanager2/v)](//packagist.org/packages/yireo/magento2-googletagmanager2) [![Total Downloads](https://poser.pugx.org/yireo/magento2-googletagmanager2/downloads)](//packagist.org/packages/yireo/magento2-googletagmanager2)  [![License](https://poser.pugx.org/yireo/magento2-googletagmanager2/license)](//packagist.org/packages/yireo/magento2-googletagmanager2)

[![ExtDN Unit Tests](https://github.com/yireo/Yireo_GoogleTagManager2/actions/workflows/extdn-unit-tests.yml/badge.svg)](https://github.com/yireo/Yireo_GoogleTagManager2/actions/workflows/extdn-unit-tests.yml)
[![ExtDN Static Tests](https://github.com/yireo/Yireo_GoogleTagManager2/actions/workflows/extdn-phpstan.yml/badge.svg)](https://github.com/yireo/Yireo_GoogleTagManager2/actions/workflows/extdn-phpstan.yml)
[![ExtDN Integration Tests](https://github.com/yireo/Yireo_GoogleTagManager2/actions/workflows/extdn-integration-tests.yml/badge.svg)](https://github.com/yireo/Yireo_GoogleTagManager2/actions/workflows/extdn-integration-tests.yml)

![Luma Themes compatible](https://img.shields.io/badge/Luma%20Themes-compatible-blue?style=flat)
![Hyvä Themes compatible](https://img.shields.io/badge/Hyv%C3%A4%20Themes-compatible-blue?style=flat)

### Need help?
We offer courses on various topics of Magento 2, including the usage and configuration of Google Tag Manager and Google Analytics. See the following course page for more details:

[yireo.com/training/magento2-gtm-advanced](https://www.yireo.com/training/magento2-gtm-advanced)

### Requirements
Supported versions: Magento 2.3.7 or higher and 2.4.1 or higher (partially because of the requirement for PHP 7.4 or PHP 8.1).

See `composer.json` for other requirements.

### See also
- [Installation](INSTALL.md)
- [Usage](USAGE.md)
- [Tutorial](TUTORIAL.md)
- [FAQ](FAQ.md)
- [Architecture](ARCHITECTURE.md)
- [Testing](TESTING.md)
- [CHANGELOG](CHANGELOG.md)
- [License](LICENSE.txt)

## Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

### [Unreleased]

### [3.10.7] - 24 February 2026
#### Fixed
- Hyva product-clicks sometimes not working because of missing parent
- Reset OrderItemDataMapper
- Created config setting to send Cart & Purchase data in base currency or store currency
- Added value and currency to `add_shipping_info` event
- Added value adjusted field in purchase DL

### [3.10.6] - 06 January 2026
#### Fixed
- Add `loki_theme` support
- Update TUTORIAL.md to remove GA4 Measurement ID
- Update gtm-example.json
- Update measurementIdOverride value in JSON
- Add check for `allowed_events` length in script-pusher

### [3.10.5] - 01 December 2025
#### Fixed
- Prevent JS errors even though parent ID will skip click tracking
- Other GitHub Action for PHPStan
- Allow dataLayerMapping DI type in all data mappers
- Explain DI types in README
- Fix view-cart event again
- Allow for DI config of `Yireo\GoogleTagManager2\Config\Source\ProductAttributes`

### [3.10.4] - 14 November 2025
#### Fixed
- Fix typo of wrong setting of $product as category

### [3.10.3] - 22 October 2025
#### Fixed
- Do not add products in event if category display mode does not show products @samicoman #266
- Make sure to trigger `view_cart` when collapsing minicart
- Make sure cart item price includes discount; Add discount, `price_excl_tax` and `price_incl_tax`
- Cart total should include discount
- Re-add `payment_method` not to break anything
- Rename `payment_method` to `payment_type` property #283
- Missing value & currency in `remove_from_cart` event #285
- Move logout event to onload event via XML layout handle `customer_account_logoutsuccess`
- Rename virtual logger to prevent DI code generation notice
- Fixes some more wrong escaping methods being used in frontend files.
- Update AddDataToCustomerSection.php
- Add more product click selectors for Hyvä

### [3.10.2] - 08 October 2025
#### Fixed
- Fix wrong encoding

### [3.10.1] - 08 October 2025
#### Fixed
- Allow CSP frame-src from googletagmanager.com

### [3.10.0] - 06 May 2025
#### Moved
- Move Hyva Checkout compat into separate package
 
#### Fixed
- Do not use custom product provider by default anymore

### [3.9.18] - 23 April 2025
#### Fixed
- PHP 8.4 compatibility issues

### [3.9.17] - 17 March 2025
#### Fixed
- Issue with js minify, script not loaded #269 @taoufiqaitali
- Fix type error when event name is empty #259

### [3.9.16] - 19 February 2025
#### Fixed
- Make sure to apply Container URL to IFRAME URL as well #267 @rikwillems

### [3.9.15] - 6 January 2025
#### Fixed
- Subtract shipping discount amount from shipping amount #248
- Subtract discount amount from subtotal

### [3.9.14] - 11 December 2024
#### Fixed
- Add payment method to order data #258 @sprankhub
- Fix issue with multiple GTM IDs #257 @taoufiqaitali

### [3.9.13] - 12 November 2024
#### Fixed
- Avoid calling function twice, data already exist #254 @taoufiqaitali
- Use price with currency instead base price #253 @florinm8
- Re-enable product details in category view #250

### [3.9.12] - 24 October 2024
#### Fixed
- Move `Model/Config/` classes to `Config/`
- Add `Funding` label to backend configuration

### [3.9.11] - 22 October 2024
#### Fixed
- Change default `category_products` to 100 because it makes more sense
- Change default `view_cart_on_mini_cart_expand_only` to 1 because it makes more sense

### [3.9.10] - 22 October 2024
#### Fixed
- Only trigger `view_cart` event when there are items in the cart
- Allow multiple GTM IDs
- Fix GTM URL

### [3.9.9] - 22 October 2024
#### Fixed
- Add new order state to `order_states_for_purchase_event` default
- New setting `googletagmanager2/settings/serverside_enabled`
- Only custom order states for `purchase` when Server-Side Tracking is enabled

_(Changelog truncated for .md surface. Full history on https://packagento.com/yireo/magento2-googletagmanager2.)_

## Recent Versions

| Version | Released |
|---|---|
| 3.10.7 | 2026-02-24 |
| 3.10.6 | 2026-01-06 |
| 3.10.5 | 2025-12-01 |
| 3.10.4 | 2025-11-14 |
| 3.10.3 | 2025-10-22 |
| 3.10.2 | 2025-10-08 |
| 3.10.1 | 2025-10-08 |
| 3.10.0 | 2025-05-06 |
| 3.9.18 | 2025-04-23 |
| 3.9.17 | 2025-03-17 |

Showing 10 of 145 versions. Full release history on https://packagento.com/yireo/magento2-googletagmanager2.

## Dependencies

### Require

| Package | Constraint |
|---|---|
| ext-dom | * |
| ext-json | * |
| ext-pcre | * |
| magento/framework | ^102.0 \|\| ^103.0 |
| magento/module-backend | ^100.0 \|\| ^101.0 \|\| ^102.0 |
| magento/module-catalog | ^100.0 \|\| ^101.0 \|\| ^102.0 \|\| ^103.0 \|\| ^104.0 |
| magento/module-catalog-search | ^100.0 \|\| ^101.0 \|\| ^102.0 |
| magento/module-checkout | ^100.1 |
| magento/module-config | ^100.0 \|\| ^101.0 |
| magento/module-configurable-product | ^100.0 |
| magento/module-cookie | ^100.0 |
| magento/module-customer | ^100.0 \|\| ^101.0 \|\| ^102.0 \|\| ^103.0 |
| magento/module-eav | ^100.0 \|\| ^101.0 \|\| ^102.0 |
| magento/module-payment | ^100.0 |
| magento/module-quote | ^101.0 |
| magento/module-sales | ^100.0 \|\| ^101.0 \|\| ^102.0 \|\| ^103.0 |
| magento/module-store | ^100.0 \|\| ^101.0 |
| magento/module-tax | ^100.0 |
| php | ^7.4\|^8.1 |
| psr/log | ^1 \|\| ^2 \|\| ^3 |
| yireo/magento2-csp-utilities | ^1.0 |

### Require (dev)

| Package | Constraint |
|---|---|
| yireo/magento2-integration-test-helper | ~0.0\|^1.0 |

### Suggest

| Package | Constraint |
|---|---|
| yireo/magento2-googletagmanager2-hyva-checkout | Use this if you are using the Hyvä Checkout |
| yireo/magento2-googletagmanager2-loki-checkout | Use this if you are using the Loki Checkout |

## Quality

Latest release (3.10.7) fails the Packagento QA pipeline. Verdicts below are per-cell (Magento line × PHP version) for the matrixed tools, and run-once for the static / security tiers.


### Compatibility

Each Magento line is installed on its supported PHP versions, then the module is built (DI compile + static-content deploy). Cells show passed / failed / untested; staircase gaps render as `–`.

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | Pass | Pass | – | – |
| 2.4.8 | – | Pass | Pass | – |
| 2.4.9 | – | – | Pass | Pass |


### Code Quality

Advisory checks against the module's source. Never affect the Compatibility verdict — a phpcs finding can't make a module incompatible.

#### Static Analysis

Coding standards (phpcs), mess detection (phpmd), copy-pasted code (cpd), PHP cross-version compatibility, composer.json validity. Each runs once for the whole module.

| Tool | Status | Findings | Summary |
|---|---|---|---|
| PHPCS | Fail | 258 | 1 error, 257 warnings (ruleset: Magento2) — 17 auto-fixable with phpcbf |
| PHPMD | Warning | 30 | 30 rule violations (UnusedFormalParameter:24, EmptyCatchBlock:6) |
| Cpd | Pass | 0 |  |
| Composer validate | Info | 1 | valid; 1 advisory note (composer validate --strict) |

#### PHPStan

Type-checks the module against a real Magento install. Re-runs per Magento + PHP version because resolvable symbols differ between releases.

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | Pass | Pass | – | – |
| 2.4.8 | – | Pass | Pass | – |
| 2.4.9 | – | – | Pass | Pass |


### Tests

Unit and integration suites run per Magento + PHP cell. Test failures speak to the module's behaviour, not its compatibility with a line, so they're reported here separately.

#### Unit Tests

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | Pass | Pass | – | – |
| 2.4.8 | – | Pass | Pass | – |
| 2.4.9 | – | – | 3 | not tested |

#### Integration Tests

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | Error | Error | – | – |
| 2.4.8 | – | Error | not tested | – |
| 2.4.9 | – | – | Error | not tested |


### Security

Dependency-advisory audit (composer audit) plus a source malware scan. A malware detection fails the version outright.

| Tool | Status | Findings | Summary |
|---|---|---|---|
| Composer audit | Pass | 0 |  |
| Malware scan | Pass | 0 |  |

## Licence and pricing

Free. A licence is still minted on checkout and bound to your project for Composer access — no payment step.

Refundable within 14 days of first purchase via https://packagento.com/account/refunds/.

## Install via Claude Code or any MCP client

The Packagento MCP server can run the licence + project + Composer steps above in one tool call:

```
purchase_and_install_packages(
  composer_names=["yireo/magento2-googletagmanager2"],
  project_id="proj_xxx"
)
```

This handles cart, checkout, licence minting, project activation, and writes auth.json credentials. Connect a client with `claude mcp add packagento https://mcp.packagento.com`. Full setup at https://packagento.com/docs/mcp-setup.

## Vendor

yireo is a Magento 2 vendor on Packagento. See https://packagento.com/yireo.md for their full catalogue.

