PHPackages                             taggrs/magento2-data-layer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. taggrs/magento2-data-layer

ActiveMagento2-module[Utility &amp; Helpers](/categories/utility)

taggrs/magento2-data-layer
==========================

This extension collect eccommerce data from Magento 2 and pushes it to the Google Tag Manager DataLayer.

v1.0.12(1y ago)519.2k↑51.8%2[1 PRs](https://github.com/TAGGRS/TAGGRS_Magento2/pulls)1GPL-3.0-or-laterPHP

Since May 29Pushed 1y ago2 watchersCompare

[ Source](https://github.com/TAGGRS/TAGGRS_Magento2)[ Packagist](https://packagist.org/packages/taggrs/magento2-data-layer)[ RSS](/packages/taggrs-magento2-data-layer/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (9)DependenciesVersions (11)Used By (1)

Taggrs GTM DataLayer for Magento 2
==================================

[](#taggrs-gtm-datalayer-for-magento-2)

This extension collect eccommerce data from Magento 2 and pushes it to the Google Tag Manager DataLayer.

Installation
------------

[](#installation)

Set your Magento store to maintenance mode.

```
bin/magento maintenance:enable
```

Install the extension via composer.

```
composer require taggrs/magento2-data-layer
```

Enable module and perform database upgrade.

```
bin/magento setup:upgrage
```

Perform dependency-injection compilation.

```
bin/magento setup:di:compile
```

Deploy static content.

```
bin/magento setup:static-content:deploy
```

Disable maintenance mode.

```
bin/magento maintenance:disable
```

Configuration
-------------

[](#configuration)

The configuration for this extension is located at

**Stores &gt; Configuration &gt; TAGGRS &gt; Data Layer**

### Google Tag Manager Settings

[](#google-tag-manager-settings)

This tab is to configure GTM.

1. **Google Tag Manager Code** enter your GTM- tracking code.
2. **Measurements API secret** enter your Google Measurements API secret.
3. **Subdomain for Enhanced Tracking Script** enter your subdomain for enhanced tracking.

### Events

[](#events)

Per-event settings to enable or disable measuring

Events
------

[](#events-1)

The events that are currently captured are:

- view\_item\_list
- view\_item
- add\_to\_cart
- remove\_from\_cart
- view\_cart
- select\_promotion
- begin\_checkout
- purchase

### view\_item\_list

[](#view_item_list)

This event is triggered on the Catalog Category pages and the Catalog Search Result page. In both cases the DataLayer is rendered in the backend.

Because of the Full Page Cache (FPC) it is necessary to retrieve the user\_data part via AJAX before pushing it to the DataLayer global.

The block for rendering the Catalog Category Datalayer is [Taggrs\\DataLayer\\Block\\Event\\CategoryViewItemList](Block/Event/CategoryViewItemList.php).

The block for rendering the Catalog Search Results DataLayer is [Taggrs\\DataLayer\\Block\\Event\\SearchResultsViewItemList](Block/Event/SearchResultsViewItemList.php).

### view\_item

[](#view_item)

This event is triggered on the Catalog Product Page. This DataLayer is rendered in the backend.

Because of the FPC it is necessary to retrieve the user\_data part via AJAX before pushing it to the DataLayer global.

The block for rendering the DataLayer is [Taggrs\\DataLayer\\Block\\Event\\ViewItem](Block/Event/ViewItem.php).

### add\_to\_cart

[](#add_to_cart)

This event is triggered when a product is added to the cart. Because adding a product to the cart is an AJAX event in Magento 2, it is necessary to render the DataLayer via an AJAX event.

The DataLayer is rendered in the following frontend controller: [Taggrs\\DataLayer\\Controller\\AddToCart\\Index](Controller/AddToCart/Index.php).

### remove\_from\_cart

[](#remove_from_cart)

This event is triggered when a product is removed from the cart. It can happen from the Minicart, or from the Checkout Cart page.

#### Minicart

[](#minicart)

Because removing a product from the cart is an AJAX event in Magento 2, it is necessary to render the DataLayer via AJAX.

Because it's impossible to retrieve information about a product that is removed from the cart, it is necessary to have the information about the cart readily available in the frontend.

This data is rendered in [Taggrs\\DataLayer\\Controller\\GetQuoteData\\Index](Controller/GetQuoteData/Index.php).

The DataLayer is built and pushed to the DataLayer global in [Taggrs/DataLayer/view/frontend/web/js/checkout-sidebar-mixin.js](view/frontend/web/js/checkout-sidebar-mixin.js).

#### Checkout Cart

[](#checkout-cart)

Because there's a redirect after removing a product from the cart it's needed to render the DataLayer in the backend and store it in the session to show it in the frontend.

The DataLayer is built in [Taggrs\\DataLayer\\Plugin\\RemoveFromCart](Plugin/RemoveFromCart.php). Which is registered as a plugin for `Magento\Checkout\Controller\Cart\Delete::beforeExecute()`.

It's then stored in the session and after the redirect it's retrieved from the session and rendered by [Taggrs\\DataLayer\\Block\\SessionDataLayer](Block/SessionDataLayer.php).

### view\_cart

[](#view_cart)

This event is triggered on the Checkout Cart page. Because the checkout pages aren't cached in the FPC it's not necessary to load the user data via AJAX.

The DataLayer is rendered in [Taggrs\\DataLayer\\Block\\Event\\ViewCart](Block/Event/ViewCart.php).

view\_cart is also triggered via AJAX if the header mini cart is opened. The AJAX DataLayer is rendered in [Taggrs\\DataLayer\\Controller\\ViewCart\\Index](Controller/ViewCart/Index.php).

### select\_promotion

[](#select_promotion)

This event is triggered when a customer applies a discount code. This can be on the Checkout Cart page or on the Checkout Payment page.

#### Checkout Cart page

[](#checkout-cart-page)

Because there's a redirect after applying a coupon, it's needed to render the DataLayer in the backend and store it in the session to show it in the frontend, just like the `remove_from_cart` event on the Checkout Cart page.

The DataLayer is built in [Taggrs\\DataLayer\\Plugin\\SelectPromotion](Plugin/SelectPromotion.php).

#### Checkout Payment page

[](#checkout-payment-page)

Because applying a coupon on the Checkout Payment page is an AJAX event, the DataLayer needs to be rendered via AJAX too.

The DataLayer is built in [Taggrs\\DataLayer\\Controller\\SelectPromotion\\Index](Controller/SelectPromotion/Index.php).

### begin\_checkout

[](#begin_checkout)

This event is triggered on the Checkout Index page. This DataLayer is rendered in the backend in [Taggrs\\DataLayer\\Block\\Event\\BeginCheckout](Block/Event/BeginCheckout.php).

### add\_shipping\_info

[](#add_shipping_info)

This event is triggered on the Checkout Index page when a logged in customer selects his shipping address, or when a guest customer enters the postcode.

The DataLayer is rendered in [Taggrs\\Datalayer\\Controller\\AddShippingInfo\\Index](Controller/AddShippingInfo/Index.php).

### add\_payment\_info

[](#add_payment_info)

This event is triggered on the Checkout Index page when a customer selects a payment method.

The DataLayer is rendered in [Taggrs\\Datalayer\\Controller\\AddPaymentInfo\\Index](Controller/AddPaymentInfo/Index.php).

### purchase

[](#purchase)

This event is triggered on the Checkout Thank You page. Because in some cases customers will not see the Checkout Thank You page, it's also needed to push the DataLayer from the backend using the Google Measurements API.

#### Checkout Thank You page

[](#checkout-thank-you-page)

This DataLayer is rendered in the backend using [Taggrs\\DataLayer\\Block\\Event\\Purchase](Block/Event/Purchase.php).

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance45

Moderate activity, may be stable

Popularity33

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 91.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~32 days

Recently: every ~39 days

Total

10

Last Release

423d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/170102627?v=4)[ITaggrs](/maintainers/ITaggrs)[@ITaggrs](https://github.com/ITaggrs)

---

Top Contributors

[![joriswebwijs](https://avatars.githubusercontent.com/u/208596714?v=4)](https://github.com/joriswebwijs "joriswebwijs (22 commits)")[![hidonet](https://avatars.githubusercontent.com/u/1196088?v=4)](https://github.com/hidonet "hidonet (1 commits)")[![NiekSchlepers](https://avatars.githubusercontent.com/u/75806175?v=4)](https://github.com/NiekSchlepers "NiekSchlepers (1 commits)")

### Embed Badge

![Health badge](/badges/taggrs-magento2-data-layer/health.svg)

```
[![Health](https://phpackages.com/badges/taggrs-magento2-data-layer/health.svg)](https://phpackages.com/packages/taggrs-magento2-data-layer)
```

###  Alternatives

[oittaa/uuid

A small PHP class for generating RFC 9562 universally unique identifiers (UUID) from version 3 to version 8.

50302.7k5](/packages/oittaa-uuid)[mbezhanov/ethereum-converter

A simple library for performing conversion between various Ethereum units

1836.7k](/packages/mbezhanov-ethereum-converter)[wbraganca/yii2-nested-set-behavior

This extension allows you to get functional for nested set trees.

229.4k](/packages/wbraganca-yii2-nested-set-behavior)[x-wp/di

The dependency injection container for WordPress

301.1k10](/packages/x-wp-di)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
