Title: Metronet Tag Manager
Author: Leon Hitchens
Published: <strong>24 Luglio 2013</strong>
Last modified: 25 Aprile 2026

---

Ricerca i plugin

![](https://ps.w.org/metronet-tag-manager/assets/banner-772x250.jpeg?rev=2788990)

![](https://ps.w.org/metronet-tag-manager/assets/icon-256x256.jpeg?rev=2788992)

# Metronet Tag Manager

 Di [Leon Hitchens](https://profiles.wordpress.org/leonhitchens/)

[Scarica](https://downloads.wordpress.org/plugin/metronet-tag-manager.1.6.0.zip)

 * [Dettagli](https://it.wordpress.org/plugins/metronet-tag-manager/#description)
 * [Recensioni](https://it.wordpress.org/plugins/metronet-tag-manager/#reviews)
 *  [Installazione](https://it.wordpress.org/plugins/metronet-tag-manager/#installation)
 * [Sviluppo](https://it.wordpress.org/plugins/metronet-tag-manager/#developers)

 [Supporto](https://wordpress.org/support/plugin/metronet-tag-manager/)

## Descrizione

Integrate Google Tag Manager into your website.

The great thing about Google Tag Manager (GTM) is that you are able to gather most
of your tracking scripts in one place. You can then fire these scripts whenever 
you want, specified by the rules you set up. This sounds great, right? Well it is.
The only problem is that sometimes it takes a bit of implementing to set these rules
up. This implementation can either be setting a dataLayer variable in the dataLayer
before the tag manager script is loaded, or pushing a HTML event handler with the
variable “event” to the dataLayer when a button is clicked. The problem is that 
this isn’t always that easy to do when you don’t have the ability/access to add 
the code to your site.

This is where the Metronet Tag Manager plugin shines. It really unlocks the power
of the dataLayer so you can easily set macros and firing rules on almost any element.

This plugin lets you:

 * Easily add as many dataLayer variables on a per-post and per-page basis as you
   need.
 * The plugin already gives you six predefined dataLayer variables that you can 
   change/remove or test the system with. These will be loaded on all pages and 
   posts.
 * Set up separate dataLayer variables for pages that aren’t posts or pages (like
   archives etc).
 * Lets you easily add a HTML event handler to any content link with the GTM TinyMCE
   button in the WYSIWYG.
 * Lets you add your own unique ID or a class to each content link with the GTM 
   TinyMCE button in the WYSIWYG.

Please note that for this plugin to work there is a slight customization that is
needed. WordPress doesn’t let you load scripts straight after the opening tag which
is where the GTM script needs to be placed to work correctly. To fix this you need
to add `<?php do_action( 'body_open' ); ?>` just after the `<body>` tag and that’s
it.

> Note, if you are using WordPress 5.2. and up, contact your theme developer and
> ask them to insert `<?php wp_body_open(); ?>` just after the opening body tag 
> of their theme. Here is some code to [show the theme developer to make it compatible with Metronet Tag Manager](https://gist.github.com/ronalfy/6b7f43e70e644320aba67d1876a0aeff).

Please let us know if you have any feature requests or if you have any issues with
this plugin.

Below are a couple of resources you might find valuable if you are new to Google
Tag Manager

Official Google Tag Manager website
 https://developers.google.com/tag-manager/

Tracking Google Analytics Events with Google Tag Manager
 http://moz.com/ugc/tracking-
google-analytics-events-with-google-tag-manager

Make Analytics Better with Tag Management and a Data Layer
 http://cutroni.com/blog/
2012/05/14/make-analytics-better-with-tag-management-and-a-data-layer/

### Filtering Variables

If you choose to place variable values inside percentage signs (e.g., %replace_test%),
you can filter these as necessary.

Here’s an example:

    ```
    add_filter( 'gtm_replace_test', 'gtm_replace_test', 10, 3 );
    function gtm_replace_test( $total_match, $match, $post_id ) {
        return "replaced with content";
    }
    ```

The filter name is `gtm_` with the suffix of `replace_test`, since that content 
is inbetween the percentage signs.

## Screenshot

[⌊Google Tag Manager account dashboard⌉⌊Google Tag Manager account dashboard⌉[

Google Tag Manager account dashboard

[⌊Google Tag Manager Workspace⌉⌊Google Tag Manager Workspace⌉[

Google Tag Manager Workspace

[⌊Recommended Google Tag Manager snippet⌉⌊Recommended Google Tag Manager snippet⌉[

Recommended Google Tag Manager snippet

[⌊Google Tag Manager snippet inside the plugin⌉⌊Google Tag Manager snippet inside
the plugin⌉[

Google Tag Manager snippet inside the plugin

## Blocchi

Questo plugin fornisce 2 blocchi.

 *   Anchor
 *   Datalayer Push

## Installazione

 1. Just unzip and upload the “metronet-tag-manager” folder to your ‘/wp-content/plugins/’
    directory
 2. Activate the plugin through the ‘Plugins’ menu in WordPress
 3. Modify your theme’s `header.php` to include `<?php do_action( 'body_open' ); ?>`
    right after the opening `<body>` tag.
 4. Go to the plugin’s settings and input your Google Tag Manager data.

> **Note**: if you are using WordPress 5.2. and up, contact your theme developer
> and ask them to insert `<?php wp_body_open(); ?>` just after the opening body 
> tag of their theme. Here is some code to [show the theme developer to make it compatible with Metronet Tag Manager](https://gist.github.com/ronalfy/6b7f43e70e644320aba67d1876a0aeff).

For custom values, [please see the filters section on GitHub](https://github.com/ronalfy/metronet-tag-manager#filtering-variables).

## FAQ

### What is Google Tag Manager

Please refer to the [Google Tag Manager FAQ](http://www.google.com/tagmanager/faq.html).

### What are dataLayer variables?

Please refer to the [Google Tag Manager API](https://developers.google.com/tag-manager/reference)
reference.

### What are dataLayer variables used for?

The data layer is an object that contains the information that you want to pass 
to Google Tag Manager. By setting up rules in Google Tag Manager, these variables
can then be used to include the correct snippets or scripts – for example when a
certain button is clicked.

### Can I have dynamic values?

Yes. For custom values, [please see the filters section on GitHub](https://github.com/ronalfy/metronet-tag-manager#filtering-variables).

## Recensioni

![](https://secure.gravatar.com/avatar/589cad59ec3e6f214af8a9174d81379fac08a5c290ca52b618c1f38d341cb5e5?
s=60&d=retro&r=g)

### 󠀁[Makes Installing Tag Manager Easy](https://wordpress.org/support/topic/makes-installing-tag-manager-easy/)󠁿

 [kdubbau](https://profiles.wordpress.org/kdubbau/) 17 Ottobre 2022

My go to when getting Google Tag Manager set up on a clients site. Very simple and
have had no problems setting it up on any of my wordpress sites. I prefer this plugin
over similar plugins due to its simplicity and has been more secure than others.
While it is simple, don't assume it can't handle the bigger projects. It allows 
the more robust tracking methods and practices some clients need that other plugins
simply don't offer. Just be sure to follow the installation instructions and you
will be good to go!

![](https://secure.gravatar.com/avatar/0472e48ea06c2961fca434202b4b8b6ae468a31b9b8889d8be1e73833494929c?
s=60&d=retro&r=g)

### 󠀁[Easily Add GTM to any Website](https://wordpress.org/support/topic/easily-add-gtm-to-any-website/)󠁿

 [Leon Hitchens](https://profiles.wordpress.org/leonhitchens/) 10 Ottobre 2022

The plugin is helpful with installing Google Tag Manager. Works on WordPress multisite
websites. The plugin is simple, straightforward, and more secure than a simple "
insert headers or footers" plugin.

![](https://secure.gravatar.com/avatar/b8c8c439356b92f205a7a4e2be8e4819a60758ce031be133927e8848831b9356?
s=60&d=retro&r=g)

### 󠀁[Decent](https://wordpress.org/support/topic/decent-17/)󠁿

 [paulbuikstra](https://profiles.wordpress.org/paulbuikstra/) 19 Luglio 2018 1 risposta

I could not verifie the search console via tag manager using this plugin. It places
the code in the wrong place. Maybe i did something wrong, but it's something you
should look in to.

![](https://secure.gravatar.com/avatar/410e9151d7756b17c7150b455149f9bc0ad0e7cdc41cc58dd178f8e551ffa0f7?
s=60&d=retro&r=g)

### 󠀁[This plugin is awesome](https://wordpress.org/support/topic/this-plugin-is-awesome-54/)󠁿

 [gubbigubbi](https://profiles.wordpress.org/gubbigubbi/) 5 Ottobre 2017 1 risposta

Simple, unobtrusive – great plugin. And whenver i see the name i always think "If
young metro don't trust you?"

![](https://secure.gravatar.com/avatar/8e6a7b2100a43d23adfde1cba22a0d1da2a60278758d6ece7e55929078cd8344?
s=60&d=retro&r=g)

### 󠀁[GTM Plugin with dataLayer Variables !?!](https://wordpress.org/support/topic/gtm-plugin-with-datalayer-variables/)󠁿

 [laurieheer](https://profiles.wordpress.org/laurieheer/) 3 Settembre 2016

I offer Google Analytics training and students always struggle with adding dataLayer
variables. Your plugin really simplifies the process – Thank You!

![](https://secure.gravatar.com/avatar/462aa2310f3e34f22fc5261d254254c8a13659dceca8c3c49f970479223db9a8?
s=60&d=retro&r=g)

### 󠀁[Great plugin](https://wordpress.org/support/topic/great-plugin-7691/)󠁿

 [Vladislav Khusainov](https://profiles.wordpress.org/pacifik/) 3 Settembre 2016
1 risposta

Turn on support for translation into other languages. Did the translation into Russian,
could not to apply)

 [ Leggi tutte le recensioni di 8 ](https://wordpress.org/support/plugin/metronet-tag-manager/reviews/)

## Contributi e sviluppo

“Metronet Tag Manager” è un software open source. Le persone che hanno contribuito
allo sviluppo di questo plugin sono indicate di seguito.

Collaboratori

 *   [ Leon Hitchens ](https://profiles.wordpress.org/leonhitchens/)
 *   [ Ronald Huereca ](https://profiles.wordpress.org/ronalfy/)
 *   [ Marco Pereirinha ](https://profiles.wordpress.org/pereirinha/)

“Metronet Tag Manager” è stato tradotto in 1 lingua. Grazie a [chi traduce](https://translate.wordpress.org/projects/wp-plugins/metronet-tag-manager/contributors)
per il contributo.

[Traduci “Metronet Tag Manager” nella tua lingua.](https://translate.wordpress.org/projects/wp-plugins/metronet-tag-manager)

### Ti interessa lo sviluppo?

[Esplora il codice](https://plugins.trac.wordpress.org/browser/metronet-tag-manager/)
segui il [repository SVN](https://plugins.svn.wordpress.org/metronet-tag-manager/),
segui il [log delle modifiche](https://plugins.trac.wordpress.org/log/metronet-tag-manager/)
tramite [RSS](https://plugins.trac.wordpress.org/log/metronet-tag-manager/?limit=100&mode=stop_on_copy&format=rss).

## Changelog

#### 1.6.0

 * Released 2026-04-24
 * Tested up to WordPress 7.0.
 * Fixed plugin URI pointing to wrong plugin slug (was metronet-profile-picture,
   now metronet-tag-manager), resolving false-positive security scanner alerts.
 * Added GTM tag output on the WordPress login page — new “Enable on login page”
   toggle in settings.
 * Fixed %category% and similar placeholders being incorrectly stripped during sanitization;
   reworked sanitize_value() to preserve any %placeholder% token regardless of surrounding
   text.
 * Wired up Gutenberg REST API route for reading and saving per-post dataLayer variables(
   previously register_routes() was empty dead code).
 * WPCS 3.0 compliance: renamed getMessage() to get_message(), replaced curl with
   wp_remote_get(), added $wpdb->prepare() in uninstall.php.
 * Added five new built-in dataLayer variable placeholders: %category% (primary 
   category slug), %tags% (comma-separated tag slugs), %post_id% (numeric post ID),%
   permalink% (canonical URL), %language% (site locale via get_locale()).
 * Added Google Consent Mode v2 support: configurable default consent states (analytics_storage,
   ad_storage, ad_user_data, ad_personalization, functionality_storage, personalization_storage,
   security_storage) output as a gtag() call before the GTM snippet.
 * Added Settings Import/Export: export all plugin settings as a JSON file and re-
   import them on another site via the admin UI.
 * Added Conditional Tag Loading: new checkboxes to exclude GTM from logged-in users
   and/or mobile devices (uses wp_is_mobile()).
 * Added standalone Gutenberg block metronettagmanager/datalayer-push — insert a
   button anywhere in the block editor; configure the event name, key, and value
   in the block inspector; renders a frontend button that fires dataLayer.push()
   on click.

#### 1.5.5

 * Released 2023-06-24
 * Adding ability to update header message remotely.

#### 1.5.4

 * Released 2019-07-16
 * Adding GTM dataLayer on search pages.

#### 1.5.3

 * Released 2019-07-16
 * Added Beaver Builder compatibility.

#### 1.5.2

 * Released 2019-05-24
 * Updating documentation.
 * Adding option to hide GTM data layer settings on posts/pages.

#### 1.5.1

 * Released 2019-05-21
 * Added support for WordPress 5.2’s wp_body_open tag.

#### 1.5.0

 * Released 2018-11-24
 * Added Gutenberg inline option for setting a dataLayer variable

#### 1.3.0

 * Released 2018-07-25
 * Fixed a bug when saving and outputting Google Tag Manager snippets where an ampersand
   HTML entity was added to the output.

#### 1.2.9

 * Released 2018-04-24
 * Fixed serious security issue. Please Update.

#### 1.2.7

 * Released 2017-11-15
 * Fixing issues in the admin where HTML elements were escaped accidentally.

#### 1.2.3

 * Updated 2017-08-10
 * Adding style element support

#### 1.2.1

 * Updated 2017-05-02
 * Code cleanup and remediation by 10up

#### 1.2.0

 * Updated 2016-11-08
 * Able to adhere to the new tag recommendations of inserting tag markup in the 
   header and also after the body tag

#### 1.1.0

 * Updated 2016-04-08
 * Improved sanitization for custom values
 * Added support for CloudFlare arguments in GTM code
 * Prevent non-filtered custom value from being outputted in the dataLayer

#### 1.0.8

 * Updated 2016-03-25
 * Allow arrays/objects in dataLayer as JSON arguments

#### 1.0.6

 * Updated 2015-08-20 – WordPress 4.3
 * Released 2015-04-03
 * Bug fix – Allow periods in datavariables to comply with GTM 2.0.

#### 1.0.5

 * Updated 2014-12-11 – Ensuring WordPress 4.1 compatibility
 * Released 2014-09-11
 * Fixed anonymous function crashing PHP < 5.3 users

#### 1.0.4

 * Released 2014-08-27
 * Fixed meta problem with datavariables showing up in areas where there aren’t 
   posts or pages
 * Ensuring WordPress 4.0 compatibility

#### 1.0.3

 * Released 2014-07-08
 * Migration to TinyMCE 4
 * Translations template

#### 1.0.2

 * Released 2013-07-30
 * Documentation update

#### 1.0.1

 * Released 2013-07-24
 * Fixing TinyMCE JavaScript issue

#### 1.0

 * Initial release.

## Meta

 *  Versione **1.6.0**
 *  Ultimo aggiornamento **7 mesi fa**
 *  Installazioni attive **20.000+**
 *  Versione WordPress ** 4.2 o superiore **
 *  Testato fino alla versione **7.0.8**
 *  Lingue
 * [English (US)](https://wordpress.org/plugins/metronet-tag-manager/) e [Japanese](https://ja.wordpress.org/plugins/metronet-tag-manager/).
 *  [Traduci nella tua lingua](https://translate.wordpress.org/projects/wp-plugins/metronet-tag-manager)
 * Tag
 * [google](https://it.wordpress.org/plugins/tags/google/)[google tag manager](https://it.wordpress.org/plugins/tags/google-tag-manager/)
   [tag manager](https://it.wordpress.org/plugins/tags/tag-manager/)
 *  [Visualizzazione avanzata](https://it.wordpress.org/plugins/metronet-tag-manager/advanced/)

## Valutazioni

 4.8 su 5 stelle.

 *  [  7 recensioni a 5-stelle     ](https://wordpress.org/support/plugin/metronet-tag-manager/reviews/?filter=5)
 *  [  0 recensioni a 4-stelle     ](https://wordpress.org/support/plugin/metronet-tag-manager/reviews/?filter=4)
 *  [  1 3- recensioni a stelle     ](https://wordpress.org/support/plugin/metronet-tag-manager/reviews/?filter=3)
 *  [  0 recensioni a 2-stelle     ](https://wordpress.org/support/plugin/metronet-tag-manager/reviews/?filter=2)
 *  [  0 recensioni a 1-stelle     ](https://wordpress.org/support/plugin/metronet-tag-manager/reviews/?filter=1)

[La tua recensione](https://wordpress.org/support/plugin/metronet-tag-manager/reviews/#new-post)

[Vedi tutte le recensioni](https://wordpress.org/support/plugin/metronet-tag-manager/reviews/)

## Collaboratori

 *   [ Leon Hitchens ](https://profiles.wordpress.org/leonhitchens/)
 *   [ Ronald Huereca ](https://profiles.wordpress.org/ronalfy/)
 *   [ Marco Pereirinha ](https://profiles.wordpress.org/pereirinha/)

## Supporto

Hai qualcosa da dire? Ti serve aiuto?

 [Chiedi nel forum di supporto](https://wordpress.org/support/plugin/metronet-tag-manager/)

## Dona

Vuoi supportare lo sviluppo di questo plugin?

 [ Fai una donazione per questo plugin ](https://mediaron.com/contribute/)