-
-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Positioning of GTM code #1426
Comments
Ah i think this might be a duplicate of #1417 |
Your solution in #1417 was to tweak the GA script in the tracking scripts area, but because we do not have access to the wrapping I'm struggling to work out how to actually just render the GTM tag inbetween those 2 tags. |
Ok, so i've got to this:
With automatic rendering disabled. Ideally I wouldn't want to disable automatic rendering though, so open to your ideas/suggestions on this one. The Maybe it would be good if you could add another node to the JSON of It would be great to be able to do something like (with automatic rendering turned on): in the
in the
But currently, the |
You do, in that you can add whatever attributes you want to it: The ability to do that was added specifically to allow you to work with things like CookieBot, CookieConsent, etc. |
Hi Andrew, thanks for getting back to me, but what I meant by my comment about 'not having access to the In a nutshell, SEOMatic forces itself to insert the script tag into the source just before the I need to do this:
plz obi wan welch, you're my only hope! |
For me this final method appears to work fine, however it looks to me like SEOmatic is rendered too far down the head. In my Google Tag Assistant, it complains that the default consent state wasn't set in time. If I hardcode the gtag consent + gtm tag directly in the head as the first thing, the error goes away. |
Yes, I'm currently just hardcoding it all into the head which is a shame :( |
I'm going to re-open this to see if there's something more interesting I can do about it |
Thanks @khalwat , I really appreciate all your work and how many hours your plugins have saved me, so I hope you haven't thought I was moaning too much in this thread! If you look at the https://support.cookiebot.com/hc/en-us/articles/360009192739-Google-Tag-Manager-and-Automatic-cookie-blocking page, and code example on that page, I guess my request would be "how could I replicate this identically with the GTM tracking scripts area in SEOMatic, with the proviso that |
Relevant here is also: https://developers.google.com/tag-platform/security/guides/consent?consentmode=advanced I think it's possible that if I bake this into the scripts in SEOmatic, this might get us most of the way there |
My only thought is that maybe Otherwise, the main issue I had in a nutshell was that SEOmatic injected the script right before the closing |
I think this is tangentially related to this issue. I noticed today that Google will no longer verify your site using the SEOmatic injected code format of placing the js link in the body. The gtag install instructions now specify everything needs to be at the top of the head including the linked script and it seems like if it's not at least in the head then there can be issues getting analytics running. Obviously there are other ways to verify or put the code in but ideally it would be supported in SEOmatic since I usually leave this stuff for the client to deal with. |
@pixelmachine thanks I'll adjust the code to do that (but no, it's not related to this issue at all, because it's regarding gtag, not GTM, and it has nothing to do with the Cookie Consent issues described in this issue). |
@robzor So my idea on this would be that there's an additional script you can enable, but I don't really want to get into adding every possible Cookie* implementation to SEOmatic. So I'm thinking I might add a Before & After script field in SEOmatic for each Tracking Script, where you can put whatever you want in there, and have it load as you like. This would also solve the unrelated problem with Google's change to their recommendations of how to implement |
Thanks @khalwat |
Hi @khalwat , sorry I was away on holiday. The idea of a before and after field could work, sounds good to me :) |
Question
Hi there,
I am trying to control the source order of the GTM script element in the section of my template. It appears that SEOmatic always injects right before the closing
</head>
tag.I am trying to do this to implement the CookieBot auto mode along with Google Consent Mode and GTM, which requires a specific source order:
This is my current code:
On a dev/staging environment, the GTM script from SEOMatic gets placed after the CookieBot code in the source HTML instead of before it, making it the in 3rd place instead of 2nd. (I know that on Production I would have to first disable the rendering of the script then grab it again)
Is it possible to make the {% do %} tag respect where it is placed in the source order of the template? Or is there another tag/function I can use so that I have full control of the order?
Thanks in advance for any help you might be able to give!
The text was updated successfully, but these errors were encountered: