DEVELOPER GUIDES

Cookie consent for Google Tag Manager

It works through GTM, but injecting directly into <head> is more reliable — GTM loads after it and some scripts may slip through. If you do use GTM, the trigger must be Consent Initialization – All Pages.

Custom HTML tag
<script id="CookieFood" src="https://cookiefood.b-cdn.net/v1/consent.js" data-cfid="YOUR-ID" data-blockingmode="auto"></script>
Tag configuration
Tag type: Custom HTML Trigger: Consent Initialization – All Pages Firing order: before every marketing tag Document Write: leave unchecked

What to watch out for

The trigger must be Consent Initialization

With "All Pages" tags fire before consent and your measurement is invalid.

No manual Consent Mode v2 setup needed

CookieFood sends ad_storage, analytics_storage, ad_user_data and ad_personalization on its own.

Leave GTM tags unconditional

Blocking is handled by CookieFood. Double-gating makes tags never fire, even after consent.

Where to get your YOUR-ID

Sign up, add a domain and you get the ID right away — the scan starts by itself. The snippet never changes again; everything else is configured in your account.

Other environments