PHPackages                             centrum/module-gtm - 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. centrum/module-gtm

ActiveMagento2-module

centrum/module-gtm
==================

Lightweight Magento 2 module for Hyvä theme integrating Klaro! consent manager with self-hosted GTM (server-side). Provides complete eCommerce dataLayer, first-party cookies and defer-loaded gtag.js.

1.0.0(7mo ago)001PHP

Since Oct 3Pushed 7mo agoCompare

[ Source](https://github.com/centrum-digital/Hyva-s-GTM-Klaro)[ Packagist](https://packagist.org/packages/centrum/module-gtm)[ RSS](/packages/centrum-module-gtm/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

Hyvä GTM + Klaro Consent Module
===============================

[](#hyvä-gtm--klaro-consent-module)

This Magento 2 module provides a **self-hosted Google Tag Manager (GTM) integration** and a **lightweight Klaro! consent manager** fully optimized for the **Hyvä theme**.
It delivers a complete `dataLayer`, supports all eCommerce events, and allows custom payloads for multi-platform tracking.

The module supports multistore. This means that with this module and a single GTM server-side container you can handle any number of stores within one Magento installation. The data is separated based on the GA4 ID variable, which is passed into the payload from the module’s configuration.

The module can be quickly and easily refactored programmatically to serve solely as a dataLayer provider and to work with a cookie notice module other than Klaro.

---

✨ Features
----------

[](#-features)

- ✅ Full **eCommerce event tracking** for GTM
    - `view_item`
    - `view_item_list`
    - `add_to_cart`
    - `remove_from_cart` (detected via cart comparison)
    - checkout and purchase events
- ✅ **Ultra-light Klaro! CMP** integration for GDPR/consent management
- ✅ **First-party cookies** storage:
    - Improves attribution accuracy
    - Reduces tracking loss caused by third-party cookie restrictions (ITP, Safari, Firefox)
    - Increases data reliability for remarketing and analytics
- ✅ **Defer-loaded gtag.js**:
    - Does not block rendering
    - No impact on **LCP** (Largest Contentful Paint)
    - Keeps **Lighthouse performance score** high
- ✅ Flexible payloads:
    - Can trigger not only Google tags but also **Facebook Pixel, TikTok, LinkedIn** and any other GTM-integrated platforms
- ✅ Compatible with **Hyvä Checkout**
- ✅ Configurable through Magento admin
- ✅ Extremely lightweight and performant

---

⚙️ Configuration
----------------

[](#️-configuration)

### 0. Klaro CMP

[](#0-klaro-cmp)

- Start with the Klaro config file:
    `src/view/frontend/web/js/klaro-config.js`
- Define **purposes (goals)** and **services** according to your tracking needs.
- To remain compliant with **Google Consent Mode v2 (GCM v2)**, you must **map Klaro services to Google signals**.
    This is **mandatory** for GA4 / Google Ads to work properly.

### 1. Magento Admin Configuration

[](#1-magento-admin-configuration)

The module settings are available in:
**Stores → Configuration → General → Centrum GTM**

Required fields:

- **GA4 Measurement ID** (format: `G-XXXXXX`)
- **GTM Server-Side endpoint URL** – the endpoint where payloads will be sent. Example: ```
    https://www.example.com/data

    ```

Optional fields:

- **Conversion Label**
- **Conversion ID**
    (used for Google Ads remarketing and conversions)

### 2. GTM Server-Side Container

[](#2-gtm-server-side-container)

- In Google Tag Manager UI, create a **Server container**.
- Deploy the GTM SS container from the official Docker image.
- To support **first-party cookies**, the container must run on **your own domain** (e.g. `https://www.example.com/data`).
- Update your Nginx / Apache configuration to proxy requests to the GTM SS container on `/data`.

### 3. How the Module Works

[](#3-how-the-module-works)

- The module sends all **event payloads** (e.g. `view_item`, `add_to_cart`, `purchase`) to the GTM SS endpoint.
- The GTM SS container receives them via the **Client** component.
- Based on those events, GTM SS fires the configured **tags** (GA4, Ads, Meta, TikTok, custom tags, etc.).

### 4. GTM SS Setup

[](#4-gtm-ss-setup)

To unlock full potential:

- Configure GTM SS with **variables, triggers, and tags** to handle the payload.
- Map Magento eCommerce events to GA4 / Ads / other platforms according to your business needs.
- Ensure Klaro consent signals are respected in GTM SS (via Consent Mode v2 mapping).

---

⚙️ Requirements
---------------

[](#️-requirements)

- Magento 2.4.x
- Hyvä Theme ^1.3
- GTM Server-Side container (GTMss) properly installed and configured

---

🔧 Installation
--------------

[](#-installation)

```
composer require centrum/module-gtm
bin/magento setup:upgrade
```

---

💡 Why First-Party Cookies?
--------------------------

[](#-why-first-party-cookies)

This module stores cookies as **1st-party** (set from your own domain, not from google.com).

Benefits:

- Survives modern browser restrictions (Safari ITP, Firefox ETP).
- Much longer lifetime vs. 3rd-party cookies.
- Significantly improves attribution for Google Ads, GA4, Meta Ads, TikTok Ads.
- Increases match rate for remarketing and conversion tracking.

In short: **better tracking, more accurate campaigns, less data loss**.

---

📦 Professional Support
----------------------

[](#-professional-support)

- The module is **free and open-source**.
- Need help with GTM Server-Side setup &amp; domain integration?
    👉 We provide **one-time setup support** for **1500 USD**.
    This includes:
    - GTMss installation on your own domain
    - Variable &amp; trigger configuration
    - Verification and testing of event flow

Contact: ****

---

License
-------

[](#license)

MIT

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance63

Regular maintenance activity

Popularity1

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

227d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/99ba28f17e56558a9d10355305badeb6fa39cdf0bda1c8c28235cdf5e40eda52?d=identicon)[centrum-digital](/maintainers/centrum-digital)

---

Top Contributors

[![centrum-digital](https://avatars.githubusercontent.com/u/235841347?v=4)](https://github.com/centrum-digital "centrum-digital (4 commits)")

### Embed Badge

![Health badge](/badges/centrum-module-gtm/health.svg)

```
[![Health](https://phpackages.com/badges/centrum-module-gtm/health.svg)](https://phpackages.com/packages/centrum-module-gtm)
```

###  Alternatives

[fastly/magento2

Fastly CDN Module for Magento 2.4.x

1564.2M1](/packages/fastly-magento2)[magenest/core

Magenest Core

12327.8k13](/packages/magenest-core)[mage-os/module-automatic-translation

Automatic AI content translation for Mage-OS.

277.1k](/packages/mage-os-module-automatic-translation)[zepgram/module-rest

Technical module to industrialize API REST call with dependency injection pattern using Guzzle library

1326.2k](/packages/zepgram-module-rest)[blackbird/module-hyva-algolia-search

Blackbird\_HyvaAlgoliaSearch makes Algolia\_AlgoliaSearch compatible with Hyvä Themes

1414.9k](/packages/blackbird-module-hyva-algolia-search)[graycore/magento2-graphql-introspection-cache

1015.2k](/packages/graycore-magento2-graphql-introspection-cache)

PHPackages © 2026

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