Blocking Google Analytics code until user accept

Hejsan anyone know how to block Google analytics code until the user have accepted it?

Kind Regards


Best and most comprehensive solution I know of is Stacks4stacks mini cookie


OK Thank you, it seems to be able to block Google analytics, how I do not understand since the code needs to go in the header of the page. But I will try to figure that out.

I mean the Google Analytics code off course :-)

Fair point, I use Matomo and they seem to suggest closer to the top of the page the better.

Don’t know if Google wants to be first to track any drop offs etc. i.e. people leaving before page load complete. So that’s why they want the GA code to be the first to load.

If it’s user consent after page load it may not matter where the code is placed?

OK, I just discovered that Joe Workmans Cookie Jar stack makes it possible to insert the GA code in it. I think I will try that because I have that stack.

1 Like

Cool. Don’t have that one, does it allow you to revoke your consent?

Might as well ask as no as I’m curious: @willwood can MiniCookie load Google analytics, or others, code in the head section? Thanks


MiniCookie is exceptional for everything related to privacy, in fact it allows you to insert stacks in IF and ELSE. Therefore I can (insert in a text stack) the Google analytics code in IF and leave the ELSE blank, insert a youtube or vimeo video and before it appears ask whether to accept the cookie policy and privacy, I could make sure to display (accepting) anything.
Works perfectly with Poster2, thanks to a small stack of support inside Poster2.
A long time ago I had Cookie Jar, which I replaced with MiniCookie, because MiniCookie as well as being more flexible, for example in showing (accepting) all the stacks I want, also allows you to create a multisession for consent.
In addition to this, it also allows you to create, for example on another page, a table where all cookies and web storage are displayed, then delete them individually or all.
I can say from my little experience that Minicookie is a full stack.

Sorry my english, i use google translate.


A new stack just released

1 Like

Yes that looks really neat. Thank you. I bought it and will check it out tomorrow.


On IOS devices you webpage screen has an ‘overlay’ that can’t be cleared. I think this happens when the cookie notice can’t be dismissed because the buttons or controls are not positioned to the centre of the screen? Or it’s Safari blocking something?
Just a heads up.
I have had this on other sites and had to view them in another browser.

This is intentional and prevents visitors simply ignoring it. The only way that the Cookie Notice can be dismissed is to either enable cookies, disable cookies, or manage preferences in the Privacy Settings.

That message doesn’t appear on the screen at all. Just the overlay.

This is a real extensive stack. I just had a half hour look at it, and since for one project I need it to be in danish also, I have chosen to have a multi lingual version. There is a few places where the default language seemingly cannot be translated. Also if I set Danish as the default language, seemingly still the English language is shown. I am not sure about this, still trying to find my way around. But this is one extensive stack… my goodness… :-)

I can’t even replicate that behaviour.

If your browser language is set to English, it will display English before Danish, even if you have set Danish as the default in the Privacy Center.

I’m not aware of any text that can’t be translated. Can you PM me with specifics.

You can change the browser language in System Preferences.

1 Like

1 Blocker is blocking it. Works when I turn it off.

Edit - works ok with Crystal content blocker and with 1 blocker and some controls used.

OK thank you. I am on another project right now, so I check it again tomorrow. But thank you, and thank you for this new stack, it looks really promising.

1 Like