Skip to content

Google firing every load #7

Open

Description

@stuartcusackie

Hi, cool package but it's firing my Google tag everytime I load the page, even before I have added a chance to accept or deny.

Thanks.

Activity

  1. Alt-Ben commented on May 8, 2025

    @Alt-Ben
    Member

    Hey @stuartcusackie!

    Weird! How are you loading the tag in? It's not cached etc is it?

    Also - does it do it in private browsing (just trying to rule out anything we may have missed in cookie states).

  2. self-assigned this
    on May 8, 2025
  3. stuartcusackie commented on May 8, 2025

    @stuartcusackie
    Author

    Hi @Alt-Ben!

    • I'm trying this in incognito browsing with both static caching enable and also disabled - I get the same result each time.
    • I am a blade developer so maybe that affects things but I don't see why it would (code below)
    • I have tried wrapping the tag in nocache but that made no difference.
    • I'm using the simple popup
    • I have disabled Analytics and enabled Google
    • The gtag script is being output on every page load (screenshot below)
    • You can check out the live site here: https://iconbp.ie/ (I removed the nocache tag as it broke it completed on my live server)
    <s:nocache> 
      {{ \Statamic::tag('AltCookies:Toast')->fetch() }} 
    </s:nocache> 
    
    Image
  4. Alt-Ben commented on May 8, 2025

    @Alt-Ben
    Member

    Hey @stuartcusackie!

    Ahhh - so the feedback we've had from various SEO agencies, is that you have to load gtag regardless, it's weird, we've spent quite a while going back and forth trying to work out exactly what Google want here.

    What happens though, is right after the initialisation of gtag, we set the permissions for consent for tracking, and by default, if no cookies are set, it should set the consent to denied for everything:

    Hopefully that makes sense - there's more chat about it here: https://developers.google.com/tag-platform/security/guides/consent?consentmode=advanced#upgrade-consent-v2

    Basically, it'll init the gtag function, but then only use it to deny consent from the off, until a user consents.

    Is that okay?

  5. stuartcusackie commented on May 8, 2025

    @stuartcusackie
    Author

    Oh I see! And do you know if this is an acceptable approach for European GDPR?

    One more question if you don't mind, is there any need to wrap this tag in nocache when using full measure static caching?

    Thanks for your help!!

  6. Alt-Ben commented on May 8, 2025

    @Alt-Ben
    Member

    I think this came about because of European GDPR to be honest!

    I'm not an SEO expert by any means, so we've been driven by the SEO agencies that we work with, based in the UK, EU and other countries (US etc) - and this seems to be the approach they all recommend, so I would assume so?

    As for the nocache, I'm actually not sure - we tend to half cache most of our sites - but on the ones where it is full measure, I haven't wrapped it and it seems to work as it should. I reckon just give it a go without the nocache and see how it behaves - as it's mainly JS driven it should be fine either way!

    If not - just pop another issue together and we'll have a nosey!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions