Blocking Google Analytics cookies by country

Viewed 218

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?

1 Answers
Related