Understanding Configuration for GTM

Created on 16 January 2024, 11 months ago

Problem/Motivation

I'm having a little trouble following the docs, or at least aligning these with the moving feast of the Google concepts and ecosystem.

Up until now we've been using the Google Analytics module, but we need to start using GTM with GA4.

I've installed 2.0.x on my site, and have a GTM container with a tag linked to GA4. Based on the documentation, I understand this module will integrate the site with the Google Tag Manager (GTM) application (including adding the relevant GTM snippets where required).

The documentation states: 'to use the module, sign up for GTM and obtain a "container ID" for your website', however the module config screen asks for a Google Tag ID, with suggested formats that do not match GTM-XXXXXXX.

Should I add the container ID in this field?

Thanks!

πŸ’¬ Support request
Status

Active

Version

2.0

Component

User interface

Created by

πŸ‡¦πŸ‡ΊAustralia rsslwa

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @rsslwa
  • Issue was unassigned.
  • πŸ‡¦πŸ‡ΊAustralia rsslwa
  • πŸ‡ΊπŸ‡ΈUnited States sadman

    I was adding the GTM-XXXXXXX to the Google Tag ID section and then saving the page and it was not working on the Tag Settings tab at /admin/config/services/google-tag. At some point, I added the string in the text field and pressed enter. This then added the Tag and exposed info and fields in the Advanced Section at the bottom of the screen. Hope this helps.

  • πŸ‡ΏπŸ‡¦South Africa vlooi vlerke

    I add the GTM-xxxxxx ID and then save.

    It briefly appears as a collapsed field set under advanced settings but then disaster and the id fields return to an empty field.

    G-xxxx and GT-xxxxx ids work but GTM-xxxx does not

  • πŸ‡ΊπŸ‡ΈUnited States chrisholt

    I would love some clarification on this. Entering a GTM-xxxx container ID and saving the configuration reveals data layer options at the bottom of the screen. BUT - the GTM option wasn't working, AND the instructions explicitly ask for the tracking ID (G-xxx).

    I read in another thread that it might have something to do with 2.0.4, but I honestly have no idea...

  • πŸ‡ΊπŸ‡ΈUnited States sleewok

    I am at a loss as well...

  • πŸ‡ΊπŸ‡ΈUnited States camhoward New Hampshire, USA

    This has certainly been a challenge with conflicting sets of directions.

    Google's directions in step 2 of their "Get started with Tag Manager" help center are to "Install a web container." That page says "...select your container ID (which starts with 'GTM')." They provide example code that includes a GTM-xxxxxxxx ID.

    That page also contains a link for "Learn how to install the Google tag with a website builder or CMS" which, in turn, has a link for how to install on Drupal and directs people to use Google Analytics.

    However, the Google Analytics module on drupal.org is listed as obsolete and deprecated. It recommends using Google Tag.

    The Google Tag module requires "Google Tag ID(s) in the form of UA-xxxxx-yy, G-xxxxxxxx, AW-xxxxxxxxx, or DC-xxxxxxxx" which don't match the Google directions to install the Google Tag Manager container ID, which starts with GTM.

    The instructions from @mglaman in #3319523-8: Is Google Tag Manager using a new format for the container ID "g-xxxxx" instead of "GTM-xxxxx"? β†’ say "If you're using Google Tag Manager, configure Google Analytics (G-XXX) in Google Tag Manager's UI."

    Here's what I did:

    1. In Google Analytics, set up an account and GA4 property for the site. Added a web data stream with the specific URL of the site. That resulted in a Measurement ID tag in the form of G-xxxxxxxx.
    2. In Google Tag Manager, created a new tag of type Google Analytics, and copied the Measurement ID tag from Google Analytics into the Google Tag in Google Tag Manager.
    3. In Drupal, on the Google Tag module "Default Tag Settings" page, pasted the G-xxxxxxxx Measurement ID tag from the Google Analytics GA4 property web data stream.
    4. The Drupal site is now sending data to Google Analytics.

    It works for tracking site visits, but seems to defeat the purpose of using Google Tag Manager (GTM).

    As I understand it, the goal of GTM is that one GTM tag is installed on a website and then all tags for measuring site visits, ad conversions, etc. are set up and managed in GTM.

    The way Drupal's Google Tag module is working, it appears that as new tags are created in Google, they also have to be added in Drupal as additional tags, which bypasses using Google Tag Manager as a central place for managing tags.

    If Drupal's Google Tag module accepted a GTM tag, social media managers and ad managers could create new tags in Google Tag Manager without needing to send them to the website manager for installation in Drupal.

    I hope this is helpful in both confirming why the process is so confusing and providing one way to set it up.

    If I have missed a step or a way to install the Google Tag Manager GTM-xxxxxxxx ID in Drupal, I would love to learn more!

  • πŸ‡ΊπŸ‡ΈUnited States recrit

    @camhoward thanks for the summary of how to use 2.x. The site that I am working on does not use Google Analytics, just GTM. It seems that this can only be accomplished with the 1.x version of the module at this point.

  • πŸ‡ΊπŸ‡ΈUnited States davemaxg

    This workaround seems to work.
    https://www.drupal.org/project/google_tag/issues/3483056 πŸ› Onboarding is BROKEN - workaround downgrade to 2.0.0 to set up GTM Active

  • πŸ‡ΊπŸ‡ΈUnited States emjayess

    Like the others, I attempted to deploy the 2.0.x version of this google tag manager module on a client site, and it's a non-starter; impossible to configure with a GTM-*** identifier.

    * Attempting to enter and save a GTM-*** container identifier results in a flash of error and then simply resets the form with no useful error message whatsoever.

    The project page indicates this project is sponsored/supported by both Acquia and Google, and it (a) does not work out of the box for GTM, and (b) is confusing as hell, with either missing or incongruent documentation across D.O. and GTM getting started or support docs. As this issue was reported all the way back in January, and remains unaddressed, it would seem to reveal that neither Acquia nor Google either cares or actually supports this module.

    It was necessary to completely remove 2.0.x and roll with the 1.x version, to get tag manager connected and functioning. At this point, 2.0.x should just be flagged as unsupported.

  • πŸ‡¬πŸ‡§United Kingdom newaytech

    Hi folks. Just wanted to chime in here to say that the module does work with GTM - and the code needed in the config screen is of the format GTM-*******. I've yet to start from scratch though - so can't comment on the saving issue described.

    Then, created a GTM container - you'll use the GTM container ID in the above config field.

    You'll then need a "Google Tag" Tag in your GTM container - this is where you set your GA4 stream ID. I've also set the send_page_view param to be true here - as then you get the page view event sent within this setup tag.

    Then - you need a series of GA4 event tags for each event you want to track - support for all of them is pretty good now. You need to pull the items through the dataLayer "eventModel" - to then pass onto GA4 in a format it understands.

Production build 0.71.5 2024