PHPackages                             humanmade/hm-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. humanmade/hm-gtm

ActiveWordpress-plugin[Utility &amp; Helpers](/categories/utility)

humanmade/hm-gtm
================

Google Tag Manager Tools for WordPress

3.1.4(6mo ago)35171.0k—3.7%3[4 issues](https://github.com/humanmade/hm-gtm/issues)2GPL-3.0PHP

Since Sep 21Pushed 6mo ago18 watchersCompare

[ Source](https://github.com/humanmade/hm-gtm)[ Packagist](https://packagist.org/packages/humanmade/hm-gtm)[ RSS](/packages/humanmade-hm-gtm/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (22)Used By (2)

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

[](#google-tag-manager-tools)

Google Tag Manager template tags and settings tool. Now supports [Server Side GTM](https://developers.google.com/tag-platform/tag-manager/server-side).

v3 Breaking Changes
-------------------

[](#v3-breaking-changes)

There are some breaking changes in v3.0.0:

- data layer no longer passes `post.author_id` by default
- data layer `post.ID` renamed to `post.id`
- data layer `term.ID` renamed to `term.id`
- data layer `author.ID` renamed to `author.id`
- data layer `user.role` is no longer an array but a comma separated list of roles
- data layer `post.` is no longer an array but a comma separated list of term names
- data layer `post.author_slug` is no longer available by default, use `post.author_name` instead

Usage
-----

[](#usage)

Once the plugin is installed and activated there are 2 places you can configure:

1. On the general settings page in admin add your container ID eg. `GTM-123ABC`
2. For a multisite install you can set a network wide container ID on the network settings screen

### Server Side GTM

[](#server-side-gtm)

You can optionally specify the following:

1. Server container URL - this should the absolute path to the server container, even if you are using a reverse proxy.
2. Custom code snippet - this is a block of code that will be added to the `` of the page. Some server side container providers have subtle or extensive changes to the standard GTM snippet so you can override it fully if needed.
3. Cookie preservation - you can set a special UUID cookie that lasts a long time, some server side providers allow restoring cookies set by 3rd parties or client side code in this way.

### No script fallback

[](#no-script-fallback)

**NOTE:** This is not needed for block themes.

If your theme is a classic theme, and you wish to support the fallback iframe for devices without javascript, add the following code just after the opening `` tag in your theme:

```

```

Data Layer
----------

[](#data-layer)

GTM offers a `dataLayer` which allows you pass arbitrary data that can be used to modify which tags are added to your site.

This plugin adds some default information such as page author, tags and categories and provides a simple filter for adding in your own custom key/value pairs.

```

```

Find out more about [using the `dataLayer` variable here](https://developers.google.com/tag-manager/devguide#datalayer).

You can explore and view the `dataLayer` variables by previewing your container and using the overlay on your website.

### Custom event tracking

[](#custom-event-tracking)

In the block editor you can add event tracking to any block via the settings panel in the block sidebar. This calls `dataLayer.push()` with the event data specified.

All blocks are opted in to support this by default, but you can set block support to false with the following during block registration, or via `block.json`. For example:

```
register_block_type( 'my-plugin/my-block', [
  'supports' => [
    'gtm' => false,
  ],
) );
```

By default the plugin will look for elements with special data attributes in your markup and listen to the specified event to push events to the data layer.

The data attributes are:

- `data-gtm-on`: *enum* \[click|submit|keyup|focusin|focusout|mouseenter|mouseleave\] The JS event to listen for, defaults to 'click'.
- `data-gtm-event`: *string* The name or action of the event eg. "play".
- `data-gtm-category`: *string* Optional group the event belongs to.
- `data-gtm-label`: *string* Optional human readable label for the event.
- `data-gtm-value`: *number* Optional numeric value associated with the event eg. product price.
- `data-gtm-fields`: *string* Optional extra data provided as encoded JSON.
- `data-gtm-var`: *string* Optionally override the default dataLayer variable name for this event.

Example:

```

  Play video

```

There is also a helper function to return these data attributes called `get_gtm_data_attributes()`.

To deactivate custom event tracking use the following code:

```
add_filter( 'hm_gtm_enable_event_tracking', '__return_false' );
```

###  Health Score

54

—

FairBetter than 97% of packages

Maintenance63

Regular maintenance activity

Popularity43

Moderate usage in the ecosystem

Community29

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 71.6% 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 ~144 days

Recently: every ~106 days

Total

19

Last Release

203d ago

Major Versions

1.1.0 → 2.0.02019-04-15

2.1.2 → 3.0.02024-07-15

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/21655?v=4)[Ryan McCue](/maintainers/rmccue)[@rmccue](https://github.com/rmccue)

![](https://www.gravatar.com/avatar/77dbeefb7745010589603f2ffc6ff310d8f700b58e08d52af190744c43342526?d=identicon)[roborourke](/maintainers/roborourke)

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

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

---

Top Contributors

[![roborourke](https://avatars.githubusercontent.com/u/23417?v=4)](https://github.com/roborourke "roborourke (68 commits)")[![ivankristianto](https://avatars.githubusercontent.com/u/656006?v=4)](https://github.com/ivankristianto "ivankristianto (5 commits)")[![Sephsekla](https://avatars.githubusercontent.com/u/33831317?v=4)](https://github.com/Sephsekla "Sephsekla (4 commits)")[![tomjn](https://avatars.githubusercontent.com/u/58855?v=4)](https://github.com/tomjn "tomjn (4 commits)")[![rmccue](https://avatars.githubusercontent.com/u/21655?v=4)](https://github.com/rmccue "rmccue (3 commits)")[![goldenapples](https://avatars.githubusercontent.com/u/665992?v=4)](https://github.com/goldenapples "goldenapples (3 commits)")[![claytoncollie](https://avatars.githubusercontent.com/u/4236538?v=4)](https://github.com/claytoncollie "claytoncollie (3 commits)")[![svandragt](https://avatars.githubusercontent.com/u/594871?v=4)](https://github.com/svandragt "svandragt (2 commits)")[![mattheu](https://avatars.githubusercontent.com/u/494927?v=4)](https://github.com/mattheu "mattheu (1 commits)")[![tareiking](https://avatars.githubusercontent.com/u/687789?v=4)](https://github.com/tareiking "tareiking (1 commits)")[![kadamwhite](https://avatars.githubusercontent.com/u/442115?v=4)](https://github.com/kadamwhite "kadamwhite (1 commits)")

### Embed Badge

![Health badge](/badges/humanmade-hm-gtm/health.svg)

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

###  Alternatives

[rainlab/blog-plugin

Blog plugin for October CMS

17257.7k](/packages/rainlab-blog-plugin)[rainlab/builder-plugin

Builder plugin for October CMS

17147.2k1](/packages/rainlab-builder-plugin)[pfefferle/wordpress-activitypub

The ActivityPub protocol is a decentralized social networking protocol based upon the ActivityStreams 2.0 data format.

5671.4k1](/packages/pfefferle-wordpress-activitypub)[civicrm/civicrm-drupal-8

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

18238.1k2](/packages/civicrm-civicrm-drupal-8)[mediawiki/semantic-glossary

A terminology markup extension with a Semantic MediaWiki back-end

1352.4k](/packages/mediawiki-semantic-glossary)[humanmade/lottie-lite

A lightweight Lottie Animations Extension for WordPress

374.3k](/packages/humanmade-lottie-lite)

PHPackages © 2026

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