Install the script
1. If you use Google Analytics / Ads / GTM — set the Consent Mode default
Put this block in the head, inline, before every Google tag (before GTM or gtag.js). Do not add async or load it from a file. Our script (step 2) loads asynchronously, so it always runs after Google tags. Without this block the first GA hit goes out with no consent state.
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){ dataLayer.push(arguments); }
gtag('consent', 'default', {
ad_storage: 'denied',
ad_user_data: 'denied',
ad_personalization: 'denied',
analytics_storage: 'denied',
functionality_storage: 'denied',
personalization_storage: 'denied',
security_storage: 'granted',
wait_for_update: 500
});
</script>Yinyom sends the consent update with the visitor’s answer for you. You do not need to write anything else.
What you will see in the Network tab before the visitor answers: the Google tag may still send a cookieless ping (gcs=G100, no user ID, no _ga cookie). That is normal Consent Mode behavior while consent is denied, and it becomes gcs=G111 after consent. If you want Google to send no request at all until consent, block the Google script with data-yy-category as described under “Block scripts that need consent” below.
2. Add the Yinyom script to your head
Place it right after the block in step 1, and before other measurement scripts where you can. If you do not use Google tags you can skip step 1.
<script src="https://cdn.kodedee.dev/yy.js" data-yyid="YOUR_SITE_ID" async></script>Find YOUR_SITE_ID on the domain settings page in the dashboard.
Block scripts that need consent
Browsers do not execute scripts whose type is not a JavaScript MIME type. We use that to block, then unlock once the visitor consents.
Before
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXX"></script>After
<script type="text/plain" data-yy-category="analytics"
async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXX"></script>The data-yy-category value must match a category key from the cookie manager, e.g. necessary, analytics, marketing.
Using Google Tag Manager
One rule: the consent default must be set before the GTM container fires its first tag.
Option A (recommended): in your site code, above GTM
In the head, in this order: (1) the consent default block from step 1, (2) the Yinyom script from step 2, (3) your usual GTM snippet.
Option B: inside GTM only (when you cannot edit the site code)
- Create a Custom HTML tag “Yinyom – consent default” containing the block from step 1, with the trigger Consent Initialization – All Pages.
- Create a Custom HTML tag “Yinyom – SDK” with the code below, with the trigger Initialization – All Pages.
- Google tags (GA4, Ads) adapt to the signals on their own. For other vendors’ tags, enable Additional consent checks in that tag’s settings.
<script>
(function () {
var s = document.createElement('script');
s.src = 'https://cdn.kodedee.dev/yy.js';
s.async = true;
s.setAttribute('data-yyid', 'YOUR_SITE_ID');
document.head.appendChild(s);
})();
</script>Check it in GTM Preview: the “Yinyom – consent default” tag must fire in Consent Initialization before any GA4 tag.
Your own cookie settings link
If you would rather not have a floating icon, turn it off in the dashboard and put this attribute on any element of yours.
<a href="#" data-yy-open-prefs>Cookie settings</a>Verify it works
- Open your site in a private window — the banner should appear.
- Press “Reject all”, then check DevTools → Application → Cookies that analytics cookies are not created.
- Back in the dashboard, a new consent record should appear within seconds.