GTM4WP – A Google Tag Manager (GTM) plugin for WordPress
Google Tag Manager (GTM) is Google’s free tool for everyone to manage and deploy analytics and marketing tags as well as other code snippets using an intuitive web UI. To learn more about this tool, visit the official website . This plugin places the GTM container code snippets onto your WordPress w
About this tool.
Google Tag Manager (GTM) is Google’s free tool for everyone to manage and deploy analytics and marketing tags as well as other code snippets using an intuitive web UI. To learn more about this tool, visit the official website .
This plugin places the GTM container code snippets onto your WordPress website so that you do not need to add them manually. Multiple containers are also supported, and each container can have its own environment parameters, custom domain and custom path.
The plugin complements your GTM setup by pushing page meta data and user information into the so-called data layer. Google’s official help pages include more details about the data layer .
PHP 8.0 and WordPress 6.3 are required to use this plugin.
GTM container code placement
The original GTM container code is divided into two parts:
The first part is a javascript code snippet that is added to the <head> section of every page of the website. This part is critical to enable all features of GTM, and this plugin helps to place this part correctly on your site.
The second part is an iframe snippet that acts as a failsafe/fallback should users’ JavaScript be disabled. Google recommends – for best performance – to place this code snippet directly after the opening <body> tag on each page.
Albeit not ideal, it will work when placed lower in the code. This plugin provides a code placement option for the second code snippet.
If your WordPress theme is compatible with the additions of WordPress 5.2, then this plugin will place this second snippet in the right place. Users of the Genesis theme, GeneratePress theme, Elementor, Oxygen Builder and Beaver Builder Theme will also have it placed correctly. To utilize this, set the compatibility mode in the plugin options to off.
All other users can place this second code snippet using custom PHP code (the “Manually coded” option), or select the so-called “Footer” option to add the code lower on the page (this is not the recommended way, but it will work).
Basic data included
- post/page titles
- post/page dates
- post/page category slugs
- post/page tag slugs
- post/page author ID and name
- post/page ID
- post types
- post format