简体   繁体   中英

Blocking Google Analytics cookies by country

When using this as part of the Google Analytics script to block cookies for EU visitors prior to consent

 gtag('consent', 'default', { 'ad_storage': 'denied', 'analytics_storage': 'denied' 'region': ['BE', 'BG', 'CZ', 'DK', 'DE', 'EE', 'IE', 'GR', 'ES', 'FR', 'HR', 'IT', 'CY', 'LV', 'LT', 'LU', 'HU', 'MT', 'NL', 'AT', 'PL', 'PT', 'RO', 'SI', 'SK', 'FI', 'SE'] });

Do I have to use the 'region': ['BE', 'BG', 'CZ', 'DK', 'DE', 'EE', 'IE', 'GR', 'ES', 'FR', 'HR', 'IT', 'CY', 'LV', 'LT', 'LU', 'HU', 'MT', 'NL', 'AT', 'PL', 'PT', 'RO', 'SI', 'SK', 'FI', 'SE'] part here as well?

 gtag('consent', 'update', { 'ad_storage': 'granted', 'analytics_storage': 'granted', 'region': ['BE', 'BG', 'CZ', 'DK', 'DE', 'EE', 'IE', 'GR', 'ES', 'FR', 'HR', 'IT', 'CY', 'LV', 'LT', 'LU', 'HU', 'MT', 'NL', 'AT', 'PL', 'PT', 'RO', 'SI', 'SK', 'FI', 'SE'] })

Is there a shorter way to specify all EU countries?

No, there is no such country as EU - it is reserved by ISO for European union

https://ec.europa.eu/eurostat/statistics-explained/index.php?title=Glossary:Country_codes

Also this might help https://developers.google.com/gtagjs/devguide/consent

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM