- Issue created by @sistro
- 🇺🇸United States solotandem
try checking a content type (or all of them)
- Status changed to Fixed
over 1 year ago 4:26pm 11 April 2023 - Status changed to Active
over 1 year ago 1:43pm 13 April 2023 - 🇦🇷Argentina hanoii 🇦🇷UTC-3
I 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 following happens and I tried to understand why it happens. The reason is that negate is
0
(numeric 0) which is then strictly compared tofalse
on:https://git.drupalcode.org/project/drupal/-/blob/af1eb719451a296bd2d7f1d...
It fails to remove it.
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 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.
- @hanoii opened merge request.
- Status changed to Needs review
over 1 year ago 1:47pm 13 April 2023 - 🇺🇸United States shaunole
I can confirm that I was able to reproduce the reported issue and the MR resolved it.
- Status changed to RTBC
over 1 year ago 10:55am 21 April 2023 - 🇮🇳India amangrover90
MR resolved the issue for a use case when tag container is saved with no conditions.
- last update
over 1 year ago 52 pass - last update
over 1 year ago 52 pass - last update
over 1 year ago 52 pass - Status changed to Fixed
over 1 year ago 5:07pm 21 April 2023 - 🇺🇸United States mglaman WI, USA
Merged! We'll make a release after a few more fixes
- 🇺🇸United States alexandersluiter
I 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.
- 🇺🇸United States mglaman WI, USA
@alexandersluiter want to open a new issue? We're leveraging the core condition plugins and instances provided by modules. It should "just work"
- 🇺🇸United States alexandersluiter
Will 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.
- 🇺🇸United States NicholasS
I 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.
- 🇺🇸United States mglaman WI, USA
@NicholasS can you open a bug? Something like "Condition plugins not evaluated properly when using Context". This needs some debugging.
- 🇦🇷Argentina hanoii 🇦🇷UTC-3
conditions: {}
means no conditions, so the tag should be displayed always, is that not what you are experiencing. - 🇺🇸United States NicholasS
@hanoii - Yes its only working when
conditions: {}
is empty. When either https://www.drupal.org/project/rules → or
https://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.
- 🇺🇸United States NicholasS
Created issue https://www.drupal.org/project/google_tag/issues/3357105 🐛 Condition plugins not evaluated properly when using Some Modules Fixed
Automatically closed - issue fixed for 2 weeks with no activity.
- Status changed to Fixed
over 1 year ago 9:34pm 1 June 2023 - 🇺🇸United States tzt20
I 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.
- 🇺🇸United States Chris Matthews
I'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 do not have any conditions.
Or, do I need to ADD conditions in order for the tag to be picked up? - 🇺🇸United States srdtwc Skokie, IL
I 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-"