Set up GTM4WP features
Google Tag Manager for WordPress adds a Google Tag Manager container to every page of your site and fills its data layer with the WordPress, visitor and store data you choose. The guides in this section explain how to set up each feature, starting with the container itself.
This page describes GTM4WP 2.1.0.
Where the settings are
In the WordPress admin, open Settings, then Google Tag Manager. The settings screen lists its sections in a sidebar; click one to open it. The Search settings box above the list narrows the sidebar to the sections whose name, option labels or option descriptions contain the text you type.
The WooCommerce and Easy Digital Downloads sections stay greyed out until a supported version of that plugin is active on the site.
The Export settings and Import settings buttons move your configuration between sites, for example from a staging copy to the live site. An import replaces every setting with the values in the file. Google service account keys are not part of the file, so add them again on the other site.
Only administrators see the settings screen by default. A developer can give it to another role with the gtm4wp_admin_page_capability filter, described on the actions and filters page.
Where to start
- Add your container. Open the Google Tag Manager container section and enter your container ID in the Google Tag Manager containers table. Until a container is set, GTM4WP writes no container code into your pages. The container settings reference describes every option of this section.
- Decide whose visits you do not want to track. The User roles to exclude option in the same section keeps the container off the pages for logged in users with the roles you select, as the guide to excluding admin users explains.
- If your visitors have to agree to tracking, set up consent mode and your consent tool before you collect data, and read the GDPR page.
- Switch on the data layer variables your tags need, and the events you want to track: user events, media players or Contact Form 7 submissions.
- If you run an online store, set up ecommerce tracking for WooCommerce or Easy Digital Downloads.
- Check the result. The GTM4WP section of WordPress Site Health shows what is switched on and runs status tests on the configuration.
All setup guides
Data Layer variables generated by GTM4WP
Which WordPress, visitor, browser, device and country variables can be read from the data layer?
Cache safe data layer + reading device data
How to set up triggers for visitor, device, customer and cart data with or without the cache safe data layer option
Exclude admin users from being tracked
How to prevent WordPress admin users from being tracked even if they have lower level roles?
Track embedded media players
How to track Vimeo, SoundCloud, Wistia, HTML5 and other media players embedded into your site?
Container settings reference
Every option in the Google Tag Manager container section of the GTM4WP settings
AMP support
How GTM4WP loads a Google Tag Manager container on the AMP version of your pages, what data it sends, and what it cannot do there?
WooCommerce related features
Set up Google Analytics 4, Google Ads conversion and remarketing tracking and many more WooCommerce related features.
How to track user interactions
Track user form interactions (entering or leaving an input), new user registration and user logins.
Track Contact Form 7 submissions
Get a Google Tag Manager event when a Contact Form 7 form is sent, fails validation or is flagged as spam.
GDPR and GTM4WP
Things to consider when managing user consent around tracking and the role of GTM4WP and Google Tag Manager in the process.
Restriction mode
Tag restrictions let you decide, from WordPress, which kinds of tags, triggers and variables are allowed to run on your site.
Consent mode and consent tools
Set up Google consent mode and connect a consent tool such as Cookiebot, CookieYes or Axeptio.
Easy Digital Downloads related features
Set up Google Analytics 4 ecommerce tracking and Google Ads conversion and remarketing tracking for Easy Digital Downloads.
Google Data Manager
Send WooCommerce and Easy Digital Downloads refunds to Google Analytics 4 from your server, with a Google service account.

