Updated: 2018/09/27 for compatibility with GTM4WP version 1.9
If you’re using WordPress, and want it measured with Google Analytics, I can heartily recommend the gtm4wp plugin. It’s free, it’s quality, and it’s very complete.
But.. after installing the plugin, and configuring it, you still have to configure your GTM container to use all the triggers and variables. That can be quite time consuming.
Until now. I’ve done the work for you and made a container you can import into your GTM workspace.
Full gtm4wp container Download
Download it from Github here – and if you find any issues, let me know.
Here’s how it works if you start from an empty container with no Google Analytics tags:
- Import the container into your workspace – and merge it. All tags come in one folder, neatly organised
- Go to the variables section and find the Google Analytics variable, and configure it to suit your needs
- change the UA variable (obviously) and other tracking properties (like ecommerce tracking)
- add any custom dimensions you want to track, using the correct CD numbers
- Preview, test, publish, audit, etc.
- Go outside and take a walk, enjoy the hour you saved.
If you’re starting from an existing container with Google Analytics tags already in place, consider:
- disabling the “Page View Tag” – you don’t want to track two pageviews per pageview.
- editing the 4 event tags to use your own GA config variable
What’s in the container?
The following gtm4wp dataLayer variables are configured:
(I’ve kept the names the same as they appear in gtm4wp, so making it easy for you to know what’s what)
- page/post variables
- pagePostAuthor
- pagePostAuthorID
- pagePostType
- pagePostType2
- pageTitle
- pageCategory
- pageAttributes
- postID
- pagePostDate
- pagePostDateYear
- pagePostDateMonth
- pagePostDateDay
- postCountOnPage
- postCountTotal
- ecomm_pagetype
- Site variables (multisite)
- siteID
- siteName
- Reading – time to Scroll
- Site Search
- siteSearchTerm
- siteSearchFrom
- siteSearchResults
- visitor info
- visitorLoginState
- visitorType
- visitorEmail – use with caution, PII. Avoid sending this to Google Analytics
- visitorRegistrationDate
- visitorId
- visitor do not track
- Contact Form 7 ID
- Contact Form 7 inputs
- Generic Form variables (for enter/leave triggers)
- formClass
- formID
- formName
- inputClass
- inputID
- inputName
- video playback variables
- mediaCurrentTime
- mediaData
- mediaData.id
- mediaData.title
- mediaPlayerState
- mediaType
- Adwords Tag Parameters (google_tag_params)
- Browser / OS / Device info
- browserName
- browserVersion
- browserEngineName
- browserEngineVersion
- osName
- osVersion
- deviceType
- deviceManufacturer
- deviceModel
- Weather
- weatherCategory
- weatherDescription
- weatherTemp
- weatherPressure
- weatherWindSpeed
- weatherWindDeg
- weatherDataStatus
The following triggers are configured:
- video triggers
- Media Player ready
- Media Player State Change
- Reading / Scrolling
- Article loaded
- Content Bottom
- Page Bottom
- Start Reading
- Contact Form 7
- Submitted
- Form Element triggers
- element enter
- element leave
- User logged in
- User registered
And finally, the Google Analytics Tags are set up as well – but you can use the above for adding other measure tools, obviously.
- Page View Tag – All Pages (please be careful if you already have one in place)
- 3 Reading events for:
- content bottom
- page bottom
- reading start
- Video event (for all video events)
- Form element enter / leave Event
- Ecommerce Events (all of them)
Next steps
There’s really loads of variables that get filled (or not, depending on your gtm4wp options). Only a few are used in tags. It’s up to you how you go about adding the variables in Page Groups, Custom Dimensions, Custom Metrics, etc. Go wild! And be careful of analysis paralysis :)
Big Thanks
To Tomas Geiger for creating the GTM plugin. Awesome timesaver, and free as well. Also, a big thanks to the #measure community for being generous in sharing loads of knowledge, work and donating so much free time to make our lives easier.
[bctt tweet=”Using the Google Tag Manager for WordPress plugin? Download a feature-complete container here.” username=”zjuul”]
Comments, remarks, feedback: very much welcome. Please leave a comment here, on github, or send me a tweet.
EC says
Am i correct in assuming that this could be used on any site regardless of whether its a WP site or not?
jules says
It’s the WordPress plugin that publishes all the
dataLayer
variables, so if you don’t use the plugin, you’re better off designing your own variable and triggering structure.John says
Hi,
I tried to import the json but got an error on parsing with the 2nd line, lang EN
jules says
Did you right-click and save? The link in the article links to the repo index.
Here’s the direct json link: https://raw.githubusercontent.com/zjuul/gtm4wp_container/master/GTM-WRMHSB8_v2.json
Hamed says
Hi Jules, Thank you so much for sharing such an amazing container. Did you try to set variables and tags when woocommerce integration is enabled?
jules says
Yes Hamed, I’ve made this container for a WooCommerce webshop I owned :)
Glad you like it!
Rob says
Hi
Instructions warn about importing if existing GA pageview set. Does that only apply within GTM or if an existing site already has GA installed?
If starting to utilise GTM, should standard GA be removed or can they exist together without conflict?
jules says
Hi Rob,
My advice would be to remove the hardcoded GA tags, and start using GTM-only.
Hardcoded GA and GTM can happily co-exists. But.. this adds lots of complexity.
– you have to make sure a pageview is sent only once
– you have to choose what to implement where, and document it
– etc.
Lokender says
Is it necessary to install plugin for working of this container?
jules says
Yes.
Peter Borg says
Hi Jules, I created a new workspace, imported the container and set the GA ID, however no tags are being fired any idea why this could be happening?
jules says
When you click “Preview” in GTM and then load your site, do you see the GTM debug pane?
Example: https://imgur.com/a/Zfai4Zt
If not, then GTM is not loaded on your site.
If yes, and you see the `gtm4wp` events on the left, then there is something wrong with the container. Let me know if this is the case, then I can take a further look. If you can send me an email with the preview-link, I can have a look myself.
Thanks!
Paola says
Hi, I’m getting a “file format is invalid” error.
JSON parsing error: mismatched input ‘”en”‘ expecting {‘{‘, ‘[‘}
What can I do?
jules says
Have you followed the link to the download page, or have you downloaded the download page?
Download page: https://github.com/zjuul/gtm4wp_container
The raw json file: https://raw.githubusercontent.com/zjuul/gtm4wp_container/master/gtm4wp_container_presets.json
Rolf says
Amazing work! Thanks!
Monica says
Thanks a lot! This container still works with the new Google Analytics 4?
Andrey says
Hi. do you plan to support GA4 on WP5.6 anytime soon?
jules says
Tomas’ plugin will add native support for GA4 soon, I believe. In the meantime, you will have to transform the ecommerce object yourself.
Here’s a good guide: https://www.tagmanageritalia.it/how-to-move-from-enhanced-ecommerce-tracking-to-google-analytics-4-ecommerce-tracking-with-google-tag-manager/
After you followed that guide, please do a pull request on github, so I can include it and everybody can use it.
Chrilles Wybrandt says
Hi,
Is this container still valid for use?
jules says
Yes, it’s still valid for universal analytics. For GA4 ecommerce, you can use the container the plugin makers have created:
https://gtm4wp.com/how-to-articles/how-to-setup-enhanced-ecommerce-tracking-google-analytics-4-ga4-version
tamr says
thank you very much for the valuable data and time placed into it
can you please update this article to fit GA 4 with woocommerce and google tag
please
thanks in advance
tamr says
the one provided by the plugin maker, it doesn’t contain customer details or order details .. it’s missing a lot of valuable data from the data layer,, along with post-reading and so on .
can you please work on one or update it accordingly and do I need to set the defined parameters in google tag into google analytic ? as custom parametars
thanks in advance
Kulkeet Nagar says
Do we need to make any changes in the JSON file or just download the file and paste it in the GA-4 account.
jules says
You’re better off importing the GA4 version of the container provided by the plugin author.
For non-ecommerce, this container is still valid. You won’t need the UA tags anymore, obviously, but the triggers and variables are working.
nahush says
Thank you for your container,as i am new to this i just wanted to know how should i change main event tag(Ga4 Configration :event) as i see all data is send to UA but i am using GA4 now.thank you
Ben says
Hi and thanks for the container!
Is there something I need to consider when using it in a serverside tagging setup? Does this container go into the tagging server container or the web server?