PHPackages                             dmitrykazak/magento-google-tag-manager - 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. dmitrykazak/magento-google-tag-manager

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

dmitrykazak/magento-google-tag-manager
======================================

Google Tag Manager (GTM) Extension for Magento 2

1.1.0(6y ago)112.8k3[2 issues](https://github.com/dmitrykazak/magento-google-tag-manager/issues)MITPHPPHP ~7.2.0|~7.3.0

Since Aug 6Pushed 6y ago5 watchersCompare

[ Source](https://github.com/dmitrykazak/magento-google-tag-manager)[ Packagist](https://packagist.org/packages/dmitrykazak/magento-google-tag-manager)[ Docs](https://github.com/dmitrykazak/magento-google-tag-manager)[ RSS](/packages/dmitrykazak-magento-google-tag-manager/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (4)DependenciesVersions (6)Used By (0)

Magento 2 GTM (Google Tag Manager)
==================================

[](#magento-2-gtm-google-tag-manager)

GTM Extension for Magento 2. GTM allows you to quickly and easily update tracking codes and related code fragments to help manage the lifecycle of e-marketing tags

Installation
============

[](#installation)

#### Step-by-step to install the Magento 2 extension through Composer:

[](#step-by-step-to-install-the-magento-2-extension-through-composer)

1. Locate your Magento 2 project root.
2. Install the Magento 2 extension using [Composer](https://getcomposer.org/)

```
composer require dmitrykazak/magento-google-tag-manager
```

3. After installation is completed the extension:

```
# Enable the extension and clear static view files
$ bin/magento module:enable DK_GoogleTagManager --clear-static-content

# Update the database schema and data
$ bin/magento setup:upgrade

# Recompile your Magento project
$ bin/magento setup:di:compile

# Clean the cache
$ bin/magento cache:flush
```

#### Manually (not recommended)

[](#manually-not-recommended)

- Download the extension of the required version
- Unzip the file
- Create a folder `{root}/app/code/DK/GoogleTagManager`
- Copy the files this folder

Magento Google Tag Manager Features
===================================

[](#magento-google-tag-manager-features)

- Measuring Product Impressions
- Measuring Product Clicks
- Measuring Views of Product Details
- Measuring Additions or Removals from a Shopping Cart
- Measuring a Checkout
- Measuring Checkout Options
- Measuring Purchases

> [More Details](https://developers.google.com/tag-manager/enhanced-ecommerce?hl=en)

#### General Configuration

[](#general-configuration)

- Login to Magento Admin, `Configuration > Sales > Google API > Google Tag Manager.`
- Enter your GTM account number

[![Settings](https://user-images.githubusercontent.com/5670207/61357887-d045e580-a881-11e9-916a-d9d8a012bfb7.png)](https://user-images.githubusercontent.com/5670207/61357887-d045e580-a881-11e9-916a-d9d8a012bfb7.png)

- Setup tags, triggers and variable in [Google Tag Manager](https://tagmanager.google.com)

#### Data Layers

[](#data-layers)

- Product Impressions

```
{
  "ecommerce": {
    "currencyCoce": "USD",
    "impressions": [
      {
        "id": "WT09",
        "name": "Breathe-Easy Tank",
        "price": "34.0000",
        "category": "Bras & Tanks",
        "brand": "Breathe-Easy Tank",
        "path": "Bras & Tanks/Women Sale/Erin Recommends/Default Category",
        "list": "Search Results",
        "position": 1
      },
      {
        "id": "WT09",
        "name": "Breathe-Easy",
        "price": "31.0000",
        "category": "Bras & Tanks",
        "brand": "Breathe-Easy Tank",
        "path": "Bras & Tanks/Women Sale/Erin Recommends/Default Category",
        "list": "Search Results",
        "position": 2
      }
    ]
  }
}
```

- Product Clicks

```
{
  "event": "productClick",
  "ecommerce": {
    "click": {
      "actionField": {
        "list": "Search Results"
      }
    },
    "products": [
      {
        "id": "WT09",
        "name": "Breathe-Easy Tank",
        "price": "34.0000",
        "category": "Bras & Tanks",
        "brand": "Breathe-Easy Tank",
        "path": "Bras & Tanks/Women Sale/Erin Recommends/Default Category",
        "list": "Search Results",
        "position": 1
      }
    ]
  }
}
```

- Product Details

```
{
  "ecommerce": {
    "detail": {
      "actionField": {
        "list": "Bras"
      }
    },
    "products": [
      {
        "id": "WT09",
        "name": "Breathe-Easy Tank",
        "price": "34.0000",
        "category": "Bras & Tanks",
        "brand": "Breathe-Easy Tank",
        "path": "Bras & Tanks/Women Sale/Erin Recommends/Default Category"
      }
    ]
  }
}
```

- Add to Cart

```
{
  "event": "addToCart",
  "ecommerce": {
    "add": {
      "products": [
        {
          "id": "WT09",
          "name": "Breathe-Easy Tank",
          "price": "34.0000",
          "quantity": 1,
          "category": "Bras & Tanks",
          "brand": "Breathe-Easy Tank",
          "path": "Bras & Tanks/Women Sale/Erin Recommends/Default Category",
          "variant": "Color:Red | Size:X"
        }
      ]
    }
  }
}
```

- Remove from Cart

```
{
  "event": "removeFromCart",
  "ecommerce": {
    "remove": {
      "products": [
        {
          "id": "WT11",
          "name": "Breathe-Easy Tank",
          "price": "69.0000",
          "quantity": 1,
          "category": "Bras & Tanks",
          "brand": "Breathe-Easy Tank",
          "path": "Bras & Tanks/Women Sale/Erin Recommends/Default Category",
          "variant": "Color:Red | Size:X"
        }
      ]
    }
  }
}
```

- Checkout

```
{
  "event": "checkout",
  "ecommerce": {
    "currencyCode": "USD",
    "checkout": {
      "actionField": {
        "step": 1,
        "option": "cart"
      },
      "products": [
        {
          "id": "WT09",
          "name": "Breathe-Easy Tank",
          "price": "34.0000",
          "category": "Bras & Tanks",
          "brand": "Breathe-Easy Tank",
          "path": "Bras & Tanks/Women Sale/Erin Recommends/Default Category",
          "variant": "Color:Red | Size:X"
        }
      ]
    }
  }
}
```

- Checkout options

```
{
  "event": "checkout",
  "ecommerce": {
    "checkout": {
      "actionField": {
        "step": 3,
        "option": "Flat Rate - Fixed"
      }
    }
  }
}
```

- Purchases

```
{
  "event": "purchase",
  "ecommerce": {
    "currencyCode": "USD",
    "purchase": {
      "actionField": {
        "id": "000000033",
        "affiliation": "Main Website Store",
        "revenue": "82",
        "tax": "0",
        "shipping": "5.0000",
        "coupon": "NEW"
      },
      "products": [
        {
          "id": "WT06",
          "name": "Breathe-Easy Tank",
          "price": "77.0000",
          "quantity": "1.0000",
          "category": "Bras & Tanks",
          "brand": "Breathe-Easy Tank",
          "path": "Bras & Tanks/Women Sale/Erin Recommends/Default Category",
          "variant": "Color:Red | Size:X"
        }
      ]
    }
  }
}
```

#### Support

[](#support)

If you encounter any problems or bugs, please open an [issue](https://github.com/dmitrykazak/magento-google-tag-manager/issues) on GitHub.

#### Customization

[](#customization)

if you want to add additional fields for product dto

- Add a new DataProvider in *di.xml*

```

                DK\GoogleTagManager\Model\DataLayer\DataProvider\CategoryId

```

- Add Custom DataProvider for fields

```
declare(strict_types=1);

namespace DK\GoogleTagManager\Model\DataLayer\DataProvider;

class CategoryId implements DataProviderInterface
{
    public function getData(array $params = []): array
    {
        return [
            'categoryId' => 1,
        ];
    }
}
```

#### Links

[](#links)

- [Contact with me](https://developer-vub3295.slack.com/messages/CLG5P5A0N)

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance16

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~19 days

Total

4

Last Release

2317d ago

### Community

Maintainers

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

---

Top Contributors

[![dmitrykazak](https://avatars.githubusercontent.com/u/5670207?v=4)](https://github.com/dmitrykazak "dmitrykazak (79 commits)")

---

Tags

ecommercegoogle-tag-managergtmmagentomagento2magento2-extensiontagmanagermagentoGoogle Tag Managergtmmagento 2magento2 extensiontag manager

### Embed Badge

![Health badge](/badges/dmitrykazak-magento-google-tag-manager/health.svg)

```
[![Health](https://phpackages.com/badges/dmitrykazak-magento-google-tag-manager/health.svg)](https://phpackages.com/packages/dmitrykazak-magento-google-tag-manager)
```

###  Alternatives

[magepal/magento2-googletagmanager

Google Tag Manager (GTM) for Magento 2 with Advance Data Layer

2671.5M4](/packages/magepal-magento2-googletagmanager)[yireo/magento2-webp2

Magento 2 module to add WebP support to the Magento frontend

2091.2M7](/packages/yireo-magento2-webp2)[xynnn/google-tag-manager-bundle

Google Tag Manager Bundle for Symfony

27718.2k1](/packages/xynnn-google-tag-manager-bundle)[cyber-duck/silverstripe-google-tag-manager

Add Tag Manager data layer, events, and ecommerce support for SilverStripe

1528.0k](/packages/cyber-duck-silverstripe-google-tag-manager)[mage2pro/currency-format

The «Price Format» extension for Magento 2

215.9k](/packages/mage2pro-currency-format)[werfu/magento2-url-key-mask

Enable Product and Category URL\_key generation using masks

135.4k](/packages/werfu-magento2-url-key-mask)

PHPackages © 2026

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