Linux 软件免费装
Banner图

GTM4WP - A Google Tag Manager (GTM) plugin for WordPress

开发者 duracelltomi
更新时间 2026年9月15日 13:35
捐献地址: 去捐款
PHP版本: 8.0 及以上
WordPress版本: 7.1
版权: GPLv3
版权网址: 版权信息

标签

google analytics google tag manager gtm google ads tag manager

下载

1.1 1.1.1 1.10.1 1.11 1.11.1 1.11.2 1.11.3 1.11.4 1.11.5 1.11.6 1.2 1.3 1.3.2 1.6.1 1.7 1.7.1 1.7.2 1.8 1.9 1.9.1 1.9.2 1.15.1 0.4 0.5.1 1.13.1 1.12.2 1.14 0.1 1.10 1.15 0.3 0.5 0.6 0.7.1 0.8 1.12 1.12.1 1.16 1.18 1.19 1.19.1 1.22.4 1.8.1 1.14.2 1.16.1 1.20.2 1.21.1 1.22 1.22.1 1.5.1 1.6 1.16.2 1.3.1 1.5 0.9 1.12.3 1.13 1.14.1 1.15.2 1.18.1 0.9.1 1.20.1 1.20.3 1.21 1.22.5 1.4 2.0.2 0.2 0.7 0.8.1 0.8.2 1.0 1.20 1.22.2 1.22.3 2.0.0 2.0.1

详情介绍:

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 Content & engagement data Optional page variables that help with behavior tracking and Google Analytics 4 content grouping: Browser / OS / Device data Data is collected in the browser using User-Agent Client Hints and pushed as a gtm4wp.deviceData event. Note that Safari and Firefox expose less detail than Chromium based browsers. Media player events Track users' interactions with any embedded media: You can choose to fire data layer events when the media player loads, when the media is played, when it is paused or stopped, and optionally when the user reaches 10, 20, 30, ..., 90, 100% of the media duration. Each event also populates Google Tag Manager's built-in Video variables (Video Status, Video URL, Video Title, Video Provider, Video Duration, Video Current Time, Video Percent, Video Visible). Tracking is supported for embedded media using the built-in oEmbed feature of WordPress, as well as most other media plugins and copy/pasted embed codes. Players inserted into the page after it has loaded (for example in a popup, a lightbox or via AJAX) can also be tracked by turning on the optional "Track dynamically inserted players" setting. Tag restrictions: allowlist & blocklist Tag Manager tags, triggers and variables To increase website security, you have the option to allowlist or blocklist tags, triggers and variables. You can prevent specific tags from firing, or prevent the use of certain variable types, regardless of your GTM setup. If the Google account associated with your GTM account is compromised, an attacker could easily execute malware on your website without accessing its code on your hosting server. By blocklisting custom HTML tags, custom JavaScript variables and sandboxed scripts (custom tag and variable templates), you can secure the Tag Manager container. Integration Google Tag Manager for WordPress integrates with several popular plugins. More integrations to come! Server side containers If you are using a server side container, you can enter your custom domain name and custom path to load gtm.js from there. Both can be set per container, so you can mix server side and standard containers on the same site. Cache-safe data layer (experimental, off by default) On sites using a full page cache (LiteSpeed, WP Rocket, Varnish, Cloudflare APO), the HTML generated for one visitor is served to everyone else as well. Any visitor specific value written into the data layer would therefore leak to other visitors - the classic example being a page cached while an editor was logged in, then served to anonymous visitors with that editor's email address and role still in the data layer. When this option is enabled, no visitor or session data is written into cacheable HTML at all. Those values are delivered in the browser instead, under the same data layer variable names, so your existing Google Tag Manager setup keeps working. Export & import your settings You can export all plugin settings into a JSON file and import them on another site, which makes it easy to roll out the same configuration across several websites. Imported files are treated as untrusted and every value is validated before it is stored. Exclude specific user roles from being tracked You can set which user roles need to be excluded from tracking when a user with that role visits the frontend. This will completely disable the container code for that user. Staging and development sites The container can be limited to production environments only, so a cloned or staging copy of your site does not send data into your production Google Tag Manager container. This relies on the WP_ENVIRONMENT_TYPE setting of WordPress. For developers Version 2.0 is a complete object oriented rewrite. Every feature is a module, and third party plugins can register their own modules through the gtm4wp_register_modules action. All public template functions, filter and action names, wp-config constants and the option storage key of the 1.x versions are unchanged, so existing integrations keep working.

安装:

  1. Upload duracelltomi-google-tag-manager-for-wordpress to the /wp-content/plugins/ directory
  2. 通过 WordPress 的“插件”菜单激活插件
  3. Go to Settings / Google Tag Manager and enter your Google Tag Manager container ID and set additional options

屏幕截图:

  • Basic settings
  • Events
  • Integration panel
  • Advanced settings

升级注意事项:

2.0.0 Major rewrite: requires PHP 8.0 and WordPress 6.3. Weather/geo data, scroll tracking and the bundled WhichBrowser library were removed. Public API (template functions, hooks, options) is unchanged. 1.22.5 Security release. Hardens how product data is written into WooCommerce product list and cart markup. Recommended for every store, and especially where users other than the site administrator can edit products. 1.22.4 Security and deprecation release. Hardens data layer and inline script encoding, and marks the features that will be removed in the upcoming GTM4WP 2.0 rewrite (geo data, weather data and scroll tracking). Those features still work in this version. 1.22.3 Bugfix release 1.22.2 Bugfix release 1.22.1 Bugfix release 1.22 Updated WhichBrowser library, new WooCommerce option, new filter for Consent Mode flags, fixes 1.21.1 Bugfix release with an XSS fix 1.21 Important update for WooCommerce users, please check the full changelog! 1.20.3 Bugfix release 1.20.2 Bugfix release 1.20.1 Bugfix release 1.20
  • Lots of deprecated features removed, please read announcement post before upgrading!
1.19.1 Bugfix release 1.19 Added features 1.18.1 Bugfix release 1.18 Bugfixes and new features

常见问题:

How can I ...

Tutorials for various Google Tag Manager settings and implementation are available on the plugin's website: https://gtm4wp.com/setup-gtm4wp-features

PayPal / 3rd party payment gateway transactions in WooCommerce are not being tracked in Google Analytics

PayPal and some other 3rd party payment gateways do not redirect users back to your website after a successful transaction by default. They offer a route back for your customer, but it can happen that users close the browser before arriving at your thank you page (also known as the order received page). This means that neither Google Analytics tags nor any other tags have a chance to fire. Enable auto-return in your payment gateway settings. This will instruct the gateway to show a quick info page after payment and redirect the user back to your site. This will improve the accuracy and frequency of tracked transactions.

Purchase event is not tracked with WooCommerce

This can happen if you are using a 3rd party plugin that alters the default order received page in a way that does not use WooCommerce's integration hooks. Either stop using that plugin, or ask its authors to mimic the behavior of the default order received page more closely by supporting the woocommerce is_order_received_page function and the woocommerce_thankyou action. Since version 2.0 the plugin also offers two settings that work around this without changing the 3rd party plugin: "Custom order received (thank-you) page" fires the purchase event on a bespoke confirmation page, and "Reliable purchase tracking" emits a missed purchase event on the next page the customer views in the same browser session. Both are de-duplicated, so an order is never counted twice.

Why isn't there an option to blocklist tag/variable classes

Although Google recommends blocklisting tags and variables using classes, people struggle to know which tags and variables get affected. Therefore I opted for individual tags and variables rather than classes on the tag restriction tabs. Regarding variables: ensure they are not part of any critical tags, as blocklisting such variables will render those tags useless.

How can I track scroll events in Google Tag Manager?

Google Tag Manager supports basic scroll depth tracking based on percentage or pixels natively. Add a Scroll Depth trigger in your container and use it to fire your Google Analytics 4 and/or Google Ads remarketing/conversion tags. (The plugin's own scroll tracking feature was removed in 2.0 in favor of this built-in GTM functionality.)

I use a page cache. Can visitor data leak between visitors?

Yes, this is a real risk with any full page cache, and it is not specific to this plugin: the HTML generated for one visitor is stored and served to everyone else. If visitor specific values (email address, user role, IP address) are written into the data layer, the cached copy will contain the values of whoever happened to trigger the caching. Turn on the "Cache-safe data layer" option to avoid this. With it enabled, no visitor or session data is written into cacheable HTML; those values are delivered in the browser instead, under the same data layer variable names.

Why does the plugin load several separate JavaScript files instead of one?

Each tracking feature (WooCommerce, each media player, Contact Form 7, device data, etc.) is its own small JavaScript file, and the plugin loads only the files a page actually needs - the YouTube tracker, for instance, loads only on pages that embed a YouTube video, and with the "defer" strategy so it never blocks rendering. Those files are already minified by the plugin's build. Merging several files into one is intentionally left to a caching / performance plugin (WP Rocket, Autoptimize, LiteSpeed Cache, etc.), which can combine scripts across your whole site and in a way that suits your hosting and HTTP setup. On modern HTTP/2 hosting, many small conditionally-loaded files usually perform as well as one combined file. (1.x combined its own scripts; 2.0 delegates this.)

更新日志:

2.0.2 2.0.1 2.0.0 Major rewrite of the plugin. Please read the announcement post on gtm4wp.com before upgrading! Architecture & requirements Settings screen Google Tag Manager container & tag restrictions Cache-safe data layer Page variables WooCommerce - Cart & Checkout blocks WooCommerce - Purchase tracking WooCommerce - Item data & extensibility filters WooCommerce - Tracking behavior & compatibility WooCommerce - Fixes Media events Consent mode & consent tools Contact Form 7 User events AMP Removed 1.22.5 A maintenance release for the 1.x line. 1.22.4 was intended to be the last one before GTM4WP 2.0; this release exists because the fixes below are worth shipping to 1.x users rather than holding for 2.0. 1.22.4 1.22.3 1.22.2 1.22.1 1.22 1.21.1 1.21 !!! WARNING !!! Significant change in WooCommerce integration! Check your template whether it supports must have hook: woocommerce_thankyou 1.20.3 1.20.2 1.20.1 1.20 THE BIG CLEANUP RELEASE! Lots of deprecated features removed. The code of WooCommerce integration was cleaned and restructured, if you have any custom code that relies on GTM4WP internal data structure, please update the plugin on a test version of your website before updating your live site! 1.19.1 1.19 WARNING! Universal Analytics / GA3 ecommerce events deprecated! Please update your GTM setup so that it does not rely on any of the following GTM4WP events and the old ecommerce data layer: 1.18.1 1.18