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

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

zdenekgebauer/google-tag-manager
================================

Google Tag Manager data layer generator

1.0.0(4y ago)03wtfplPHPPHP &gt;=8.0

Since Apr 21Pushed 4y ago1 watchersCompare

[ Source](https://github.com/zdenekgebauer/google-tag-manager)[ Packagist](https://packagist.org/packages/zdenekgebauer/google-tag-manager)[ RSS](/packages/zdenekgebauer-google-tag-manager/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

Google Tag Manager
==================

[](#google-tag-manager)

Data Layer generator

[![](https://github.com/zdenekgebauer/google-tag-manager/workflows/build/badge.svg)](https://github.com/zdenekgebauer/google-tag-manager/workflows/build/badge.svg)

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

[](#installation)

`composer require zdenekgebauer/google-tag-manager`

Usage
-----

[](#usage)

### Simple event

[](#simple-event)

```
$event = new EventShare();
$event->method = 'Twitter';
$event->contentType = 'image';
$event->itemId = 'C_12345';

echo ((new DataLayer($event))->render());  // window.dataLayer.push({"event":"share","content_type":"image","item_id":"C_12345"});
```

### Ecommerce event with items

[](#ecommerce-event-with-items)

```
$event = new EventPurchase();
$event->transactionId = '1234';
$event->value = '9.99';
$event->currency = 'USD';

$item = new Item('SKU12', 'Some gadget', 9.99, 1);
$item->brand = 'Acme';
$item->category = 'Cool Gadgets';
$event->addItem($item);

echo ((new DataLayer($event))->render());
```

### Custom content

[](#custom-content)

```
class MyDataLayerContent extends DataLayerContent
{
    public ?string $requiredProperty = null;
    public ?string $optionalProperty = null;

    public function __construct()
    {
        $this->requiredProperties = ['requiredProperty'];
    }

    /**
     * @throws Exception
     */
    public function assertValid(): void
    {
        parent::assertValid(); // check required properties
        // .... some additional check
    }

    public function jsonSerialize(): stdClass
    {
        $result = new stdClass();
        $result->required_property = $this->requiredProperty;
        Utils::addProperty($result, 'optional', $this->optionalProperty);
        return $result;
    }
}

$content = new MyDataLayerContent();
$content->requiredProperty = 'some';
echo ((new DataLayer($content))->render());  // window.dataLayer.push({"required_property":"some"});
```

Official documentation
----------------------

[](#official-documentation)

\[Google Analytics 4 events\]

\[Google Analytics 4 events for ecommerce\] [https://developers.google.com/analytics/devguides/collection/ga4/ecommerce?client\_type=gtm](https://developers.google.com/analytics/devguides/collection/ga4/ecommerce?client_type=gtm)

Licence
-------

[](#licence)

Released under the [WTFPL license](copying.txt) .

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

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

Unknown

Total

1

Last Release

1482d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/36ef4dac7600d246b5d5bf20592da1f536607276921f31000886c6350d39f278?d=identicon)[zdenekgebauer](/maintainers/zdenekgebauer)

---

Top Contributors

[![zdenekgebauer](https://avatars.githubusercontent.com/u/6378486?v=4)](https://github.com/zdenekgebauer "zdenekgebauer (1 commits)")

---

Tags

phpGoogle Tag Manager

###  Code Quality

TestsCodeception

### Embed Badge

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

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

###  Alternatives

[imanghafoori/laravel-anypass

A minimal yet powerful package to help you in development.

21421.6k](/packages/imanghafoori-laravel-anypass)

PHPackages © 2026

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