The Google tag code is not present
I installed the form and configured as well as instructions, the result does not change, no code was inserted on the pages of the site with the result with the non -functional Google tag
How I configured:
I added a container with my id
Advanced default settings
All Paths
All Roles
No block visibility group
and Other Default Settings
The only thing I tried is on content type: without checking anything (which I suppose means adding the tag everywhere) and cheking some content content type only.
In Google Tag Manager Settings I tried to:
Disable compact the javascript snippet
Disable includes The Snipper As a file
I also tried to disable modules that could give problems such advagg or cookie manager, but nothing has changed.
I tried the dev version, and nothing has changed.
Suggestions?
Issue fork google_tag-3345719
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3345719-google-tag-code
changes, plain diff MR !33
Comments
Comment #2
solotandem commentedtry checking a content type (or all of them)
Comment #3
sistro commentedI have already tried naturally!
tnx!
Comment #4
sistro commentedProblem solved!
It was my problem in the configuration and not in the module, of course!
For anyone having the same problem:
review the google tag manager module settings
if you use cookie consent manager make sure it does not block the google tag
and above all clean the browser cookies!!
Problem solved.
It was my problem in the configuration and not in the form, of course!
For anyone having the same problem:
review the google tag manager module settings
if you use cookie consent manager make sure it does not block the google tag
and above all clean the browser cookies!!
The only doubt on the module and a suggestion for future releases is in the "content type" section in the container settings. It would be useful to write "if none is enabled, the tag will be shown everywhere" (even if I have bypassed the mistake by trying the various settings (my problem was not in the configuration but elsewhere))
Comment #5
mglamanComment #6
hanoiiI think there's a critical issue with this on 2.0.0
The issue should be easy to reproduce.
- Add a single google tag with no condition
- Add a node without any taxonomy (or look at a page that's not a node)
And the google tag is not added.
I spent quite a bit of time trying to figure this out. The reason is that the empty conditions are stored in the config entity, thus requiring the element in the context (i.e. a vocabulary is expected to be gathered from the route, which is not possible if the node doesn't have any term).
I then started to look why this was happening and comparing with other visibility logic like block (which I assume is where most of the code/logic has been taken from) and found that one thing was not being done:
https://git.drupalcode.org/project/drupal/-/blob/af1eb719451a296bd2d7f1d...
When you add this, the conditions are stored properly and I tried to understand why it happens. The reason seems to be that the negate checkbox when coming from the form is
0(numeric 0) which is then strictly compared tofalseon:https://git.drupalcode.org/project/drupal/-/blob/af1eb719451a296bd2d7f1d...
so It fails to remove it when saved just once.
However, it seems that by saving it twice (one on the submit handler and they by the entityform save method()
https://git.drupalcode.org/project/google_tag/-/blob/af8ad2037b4865f5c20...
The first time it's stored, the config is updated internally to match store schema (0 becomes false), so the second time the config entity is saved, the previous code works and the conditions is ps properly filtered and stored as empty (if no conditions obviously) so now the context is no longer required.
Basically, with no conditions the tag should be displayed everywhere.
Comment #8
hanoiiMR created
Comment #9
hanoiiComment #10
shaunole commentedI can confirm that I was able to reproduce the reported issue and the MR resolved it.
Comment #11
amangrover90 commentedMR resolved the issue for a use case when tag container is saved with no conditions.
Comment #12
mglamanCrediting shaunole for testing
Comment #14
mglamanMerged! We'll make a release after a few more fixes
Comment #15
alexandersluiter commentedI am having issues with this with the group_type condition provided by the Group module. Even with this MR, it is still coming back as a condition to check. Diving into it, more to come.
Comment #16
mglaman@alexandersluiter want to open a new issue? We're leveraging the core condition plugins and instances provided by modules. It should "just work"
Comment #17
alexandersluiter commentedWill do. I'm trying to figure out which module is the offending one yet. Will create new issue here if it turns out to be this one.
Comment #18
nicholassI experienced the same difficulty in trying to get tracking code to show up on my site, I narrowed it down I think to the combination of "context" related modules. Specifically I think the drupal/context:4.x has some kind of default condition that makes it never show.
Only after I uninstalled all these (context was last, and I think the culprit) did the tag start to appear. (Core 9.5.8). After each module I removed, I uninstalled/reinstalled google_tag and saved my Google tag ID on the config page, then tested the site to see if I could find the tag.
Update: It seems to mainly be project/rules and project/context_entity_field, when either of those are installed, saving the `/admin/config/services/google-tag` from after adding only the Google Tag ID, causes the configuration YML to save with "conditions: {}" which cause the gtag to not be added.
Here are some examples of how the config changes after these modules are enabled, and the form is re-saved.
Comment #19
mglaman@NicholasS can you open a bug? Something like "Condition plugins not evaluated properly when using Context". This needs some debugging.
Comment #20
hanoiiconditions: {}means no conditions, so the tag should be displayed always, is that not what you are experiencing.Comment #21
nicholass@hanoii - Yes its only working when
conditions: {}is empty. When either https://www.drupal.org/project/rules orhttps://www.drupal.org/project/context_entity_field are installed I can't get the gtag to show, since those modules add conditions which their defaults appear to cause the gtag to not be added. Its odd since my blocks/visibility have been fine with these modules installed, just not gtag.
@mglaman - Ill open an issue.
Comment #22
nicholassCreated issue https://www.drupal.org/project/google_tag/issues/3357105
Comment #24
tzt20 commentedI appreciate the work on this. The fix in the MR works for me. I'd appreciate this fix moving into a new release soon if possible. I spent quite a bit of time on this, and I imagine others will too. With Acquia's notice to upgrade, I imagine more users will encounter this problem. Thanks again.
Comment #25
hanoii@tzt20 the latest 2.0.2 includes these fixes.
Comment #26
chris matthews commentedI'm on 2.0.2. When testing, I'm still getting: "Your Google tag wasn't detected on your website."
At /admin/config/services/google-tag, I have
Added my tag ID
Custom dimensions and metrics = None
Events
Conditions
Check this checkbox to enable Tag Container. = Enabled
=====
EDIT: Looks like the issue was I had "Collect Universal Analytics events" disabled
Comment #27
srdtwc commentedI believe I am encountering this error.
I am trying to use google_tag 2.0.2 with a tag ID begging with "GTM-". The only setting I've changed is that User Role is only Anonymous User.
When I use https://tagassistant.google.com/ It says "no tags found". I seem to be able to us tags begging with "AW-" and "G-" though, so the issue is specifically with a tag beginning with "GTM-"