Stuifbergen.com

Analytics & Growth Hacking

  • About
  • Contact
  • Professional Services

Find me here

  • Mastodon (social)
  • Mastodon (measure)
  • No more Twitter
You are here: Home / Blog / GTM For WordPress (gtm4wp) Container with Google Analytics Tags

GTM For WordPress (gtm4wp) Container with Google Analytics Tags

15 February 2018 by jules 26 Comments

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:

  1. Import the container into your workspace – and merge it. All tags come in one folder, neatly organised
  2. Go to the variables section and find the Google Analytics variable, and configure it to suit your needs
    1. change the UA variable (obviously) and other tracking properties (like ecommerce tracking)
    2. add any custom dimensions you want to track, using the correct CD numbers
    3. Preview, test, publish, audit, etc.
  3. 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:

  1. disabling the “Page View Tag” – you don’t want to track two pageviews per pageview.
  2. 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.

Related posts:

Google Tag Manager Cookie Consent dialog GTM Monitoring in Google Analytics Properly Analyze A/B Test results with Advanced Segments What’s in the reCAPTCHA field filter in Google Analytics?

Filed Under: Blog Tagged With: container, download, Google Analytics, Google Tag Manager, gtm4wp, tagging

Comments

  1. EC says

    7 March 2018 at 04:34

    Am i correct in assuming that this could be used on any site regardless of whether its a WP site or not?

    Reply
    • jules says

      7 March 2018 at 09:09

      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.

      Reply
  2. John says

    3 May 2018 at 12:26

    Hi,

    I tried to import the json but got an error on parsing with the 2nd line, lang EN

    Reply
    • jules says

      6 May 2018 at 11:27

      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

      Reply
  3. Hamed says

    13 February 2019 at 11:28

    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?

    Reply
    • jules says

      13 February 2019 at 11:35

      Yes Hamed, I’ve made this container for a WooCommerce webshop I owned :)

      Glad you like it!

      Reply
  4. Rob says

    9 April 2019 at 13:03

    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?

    Reply
    • jules says

      9 April 2019 at 14:05

      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.

      Reply
  5. Lokender says

    13 August 2019 at 20:20

    Is it necessary to install plugin for working of this container?

    Reply
    • jules says

      13 August 2019 at 21:09

      Yes.

      Reply
  6. Peter Borg says

    4 October 2019 at 10:10

    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?

    Reply
    • jules says

      4 October 2019 at 12:17

      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!

      Reply
  7. Paola says

    30 October 2019 at 09:08

    Hi, I’m getting a “file format is invalid” error.

    JSON parsing error: mismatched input ‘”en”‘ expecting {‘{‘, ‘[‘}

    What can I do?

    Reply
    • jules says

      30 October 2019 at 10:21

      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

      Reply
  8. Rolf says

    4 May 2020 at 12:29

    Amazing work! Thanks!

    Reply
  9. Monica says

    9 November 2020 at 12:55

    Thanks a lot! This container still works with the new Google Analytics 4?

    Reply
  10. Andrey says

    3 February 2021 at 10:34

    Hi. do you plan to support GA4 on WP5.6 anytime soon?

    Reply
    • jules says

      3 February 2021 at 10:49

      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.

      Reply
  11. Chrilles Wybrandt says

    28 March 2022 at 13:42

    Hi,

    Is this container still valid for use?

    Reply
    • jules says

      28 March 2022 at 13:54

      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

      Reply
  12. tamr says

    19 July 2022 at 00:22

    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

    Reply
    • tamr says

      19 July 2022 at 00:25

      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

      Reply
  13. Kulkeet Nagar says

    23 June 2023 at 11:33

    Do we need to make any changes in the JSON file or just download the file and paste it in the GA-4 account.

    Reply
    • jules says

      23 June 2023 at 13:51

      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.

      Reply
  14. nahush says

    19 November 2023 at 12:38

    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

    Reply
  15. Ben says

    18 June 2024 at 16:50

    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?

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Recent Posts

  • How to use a pre-hashed email address in GA4 tags in GTM
  • GA4 intraday exports and cookieless pings
  • July 2024 change in collected_traffic_source in GA4 Big Query
  • srsltid parameter, GA4 and Big Query
  • Smart incremental GA4 tables in Dataform

Need help?

  • Contact me

Search

© Copyright Jules Stuifbergen · Powered by Genesis ·