PHPackages                             gebruederheitz/wp-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. gebruederheitz/wp-gtm

ActiveLibrary

gebruederheitz/wp-gtm
=====================

A helper to include the Google Tag Manager in your Wordpress

v1.1.0(1y ago)0190GPL-3.0-onlyPHPPHP &gt;=7.3

Since Aug 26Pushed 1y ago2 watchersCompare

[ Source](https://github.com/gebruederheitz/wp-gtm)[ Packagist](https://packagist.org/packages/gebruederheitz/wp-gtm)[ RSS](/packages/gebruederheitz-wp-gtm/feed)WikiDiscussions develop Synced today

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

Wordpress Simple Google Tag Manager
===================================

[](#wordpress-simple-google-tag-manager)

*A helper to include the Google Tag Manager in your Wordpress.*

---

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

[](#installation)

via composer:

```
> composer require gebruederheitz/wp-gtm
```

Make sure you have Composer autoload or an alternative class loader present.

Usage
-----

[](#usage)

```
# functions.php (or controller class)
use Gebruederheitz\Wordpress\GoogleTagManager;

new GoogleTagManager();
```

```
# .env

#--------------------------------------------------------------------------------------------------#
#                                   GOOGLE TAGMANAGER                                              #
# Adds Google Tagmanager snippets                                                                  #
#--------------------------------------------------------------------------------------------------#
GTM_CONTAINER_ID=GTM-XXXXX
```

You can also add parameters to your container ID in order for example to use a staging environment.

If the environment variable is not defined, the script snippet will not be loaded, unless you provide a custom GTM container ID to the constructor.

### Passing a container ID at runtime

[](#passing-a-container-id-at-runtime)

Instead of providing the container ID through the environment, you can also pass it through the constructor – which is handy when you're providing the user with a setting through theme options in the database, for example.

```
$containerId = get_option('namespace_gtm_container_id', null);
new \Gebruederheitz\Wordpress\GoogleTagManager($containerId);
```

An ID passed to the constructor will always override the environment setting.

### Using a custom template

[](#using-a-custom-template)

By creating a file at `template-parts/blocks/gtm.php` inside your theme directory you can override the default output (replace the snippet).

Alternatively you may pass a custom path (inside your theme directory) as the constructor's second parameter and use that file instead.

```
new \Gebruederheitz\Wordpress\GoogleTagManager(null, 'partials/tagmanager.twig.php');
```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance47

Moderate activity, may be stable

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity49

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 ~661 days

Total

3

Last Release

395d ago

PHP version history (2 changes)v1.0.0PHP ^7.3

v1.0.1PHP &gt;=7.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/d2a201d58341e3ed71321bcb66cb375a8c6efffce7d8fe33244e821afc087c78?d=identicon)[mediocrity](/maintainers/mediocrity)

---

Top Contributors

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

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/gebruederheitz-wp-gtm/health.svg)

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

PHPackages © 2026

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