Movatterモバイル変換


[0]ホーム

URL:


Skip to content
Search Gists
Sign in Sign up

Instantly share code, notes, and snippets.

@kakauandme
Last activeOctober 4, 2020 23:51
    • Star(0)You must be signed in to star a gist
    • Fork(0)You must be signed in to fork a gist
    Save kakauandme/f6a93db345729c5897f3fd7c149d04ae to your computer and use it in GitHub Desktop.
    Disable Google Analytics and Google Ads cookies/identifiers for GDPR countries
    <scriptasyncdefersrc="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXX-X"></script>
    <script>
    window.dataLayer=window.dataLayer||[];
    functiongtag(){dataLayer.push(arguments);}
    gtag('consent','default',{// disable GA and Ads identifiers for GDPR countries by default
    'ad_storage':'denied',
    'analytics_storage':'denied',
    'region':['AT','BE','BG','HR','CY','CZ','DK','EE','FI','FR','DE','GR','HU','IE','IT','LV','LT','LU','MT','NL','PL','PT','RO','SK','SI','ES','SE','GB','GF','GP','MQ','ME','YT','RE','MF','GI','AX','PM','GL','BL','SX','AW','CW','WF','PF','NC','TF','AI','BM','IO','VG','KY','FK','MS','PN','SH','GS','TC','AD','LI','MC','SM','VA','JE','GG','IS','NO'],
    });
    gtag('js',newDate());
    gtag('config','UA-XXXXXXXX-X');
    document.getElementById("accept_cookies")// allow identifiers after user gives consent
    .addEventListener("click",function()
    {
    gtag("consent","update",{
    ad_storage:"granted",
    analytics_storage:"granted",
    });
    });
    // source: https://developers.google.com/gtagjs/devguide/consent
    </script>
    Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

    [8]ページ先頭

    ©2009-2025 Movatter.jp