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. [Utility &amp; Helpers](/categories/utility)
4. /
5. centrum/module-gtm

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

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(9mo ago)001PHP

Since Oct 3Pushed 9mo 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 today

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

26

—

LowBetter than 41% of packages

Maintenance58

Moderate activity, may be stable

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

273d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/235841347?v=4)[centrum-digital](/maintainers/centrum-digital)[@centrum-digital](https://github.com/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

[nosto/module-nostotagging

Increase your conversion rate and average order value by delivering your customers personalized product recommendations throughout their shopping journey.

27703.7k4](/packages/nosto-module-nostotagging)[tig/postnl-magento2

TIG Magento 2 PostNL extension

59570.5k5](/packages/tig-postnl-magento2)[myparcelnl/magento

A Magento 2 module that creates MyParcel labels

1860.2k](/packages/myparcelnl-magento)[loki/magento2-components

Core module for defining Alpine.js components with advanced AJAX features

1011.8k26](/packages/loki-magento2-components)[zwernemann/module-withdrawal

Magento 2 EU Withdrawal Button Module - Adds a withdrawal/revocation button for orders in compliance with EU Directive (EU) 2023/2673

244.8k2](/packages/zwernemann-module-withdrawal)[angeo/module-llms-txt

Magento 2 module for AI Engine Optimization (AEO). Generates spec-compliant llms.txt and llms-full.txt per llmstxt.org standard, plus streaming JSONL for vector indexing. Multi-store, multi-website, CLI, cron, async admin UI, Page Builder-aware sanitization, customer-group pricing, atomic writes, ETag/Cache-Control, .md mirrors.

111.1k](/packages/angeo-module-llms-txt)

PHPackages © 2026

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