Region-specific tags behavior in Google Tag Manager

Jun 6, 2024
Jun 22, 2023
Also available in

Region-specific tag behavior in Google Tag Manager refers to the ability to customize the firing of tags based on the user's geographic location. It allows you to define rules and conditions that determine when tags should be triggered or not triggered based on the user's region.

With region-specific tag behavior, you can target or exclude certain regions from receiving specific tags. This can be useful when dealing with tracking rules in certain countries, like consent banners or user data anonymization in the European Union. 

In this blog post, we will talk about region-specific tag behavior, how to set it up for the App Engine, geo headers power-up from stape, and how to use region-specific tag behavior for triggering consent banners.

What is region-specific tag behavior in server Google Tag Manager?

Region-specific tag behavior is one of the newest features of Google Analytics 4 client in server Google Tag Manager.

Region-specific tag behavior does two main things:

  • Adds a country code to the server Google Analytics 4 headers. 
ga4 client configuration
  • Adds the same country code to the Visitor Region variable.
country code to the Visitor Region variable

Please remember any method of determining a user's location can be blocked or skewed by various user settings or tools (e.g., VPNs), so it won't be 100% accurate.

Be sure to follow all applicable privacy laws and regulations when implementing any kind of geolocation tracking.

Benefits of using region-specific tag behavior in GTM

Region-specific tag behavior in Google Tag Manager can offer several potential benefits for your website, primarily if your audience is distributed across various geographic regions, and you must respect tracking restrictions in each region, and provide different user experiences or marketing efforts based on their locations. Here are a few key benefits:

  1. Legal Compliance. In some cases, laws or regulations may dictate what kind of data you can collect from users in certain regions. For example, the EU's General Data Protection Regulation (GDPR) has strict data collection and user consent requirements. By using region-specific tags, you can ensure that you're only collecting data in ways that are legal and compliant with regional regulations.
  2. Better data quality. By triggering a consent banner or anonymizing user data only for those countries where it’s required by law, you improve the data quality.
  3. Marketing Optimization. Region-specific tagging can help you optimize your marketing efforts. For example, users in a specific region respond better to a particular promotional activity, and you can use region-specific tags to collect those people into separate audiences.
  4. Improved User Experience. You can increase user engagement and satisfaction by customizing and tailoring the user experience to be more relevant and appropriate for their region.
  5. Performance Optimization. You can serve different versions of scripts or tags depending on the region, which can help improve the performance of your website for users in other locations.
  6. A/B Testing. Region-specific tags can help you conduct location-based A/B testing to determine what works best for audiences in different regions.

Remember, while these benefits can be achieved with region-specific tags in GTM, proper setup and ongoing management are essential to ensure you get the most out of this feature. Always be aware of the privacy and legal implications when dealing with user data and location-based customization.

Configure region-specific tag behavior using App Engine

Setting up GEO headers that are responsible for region-specific tag behavior depends on what cloud provider you use to host your server Google Tag Manager. If you are interested in how to configure GEO headers if you are using stape, then go to the next chapter. 

Besides stape, there are two main ways of configuring GEO headers:

  • Use the App Engine as a server provider for sGTM. The process of setting up GEO headers is semi-automatic, and I will talk about it in this chapter.
  • Any other server providers for sGTM. In this case, you must set up GEO headers manually. Please refer to this official documentation.

To unlock region-specific tag behavior in App Engine, follow these steps:

1. Confirm first-party script serving is set up. It means that gtm.js loads from your custom domain. 

2. Create a Visitor Region variable in server GTM.

Visitor Region variable in server GTM

3. Enable region-specific settings in the GA4 client and select the Visitor Region variable you’ve recently created. 

region-specific settings in the GA4 client

Configure region-specific tag behavior using Stape GEO headers power up

  1. Enabling GEO headers on stape is simple. You can do it by opening sGTM container, clicking on the Power-ups tab, and clicking use GEO headers. 

Unlike App Engine, stape GEO header power-up will allow you to see the user’s GEO data whether you use a custom domain or not.

geo header power-up by stape

2. Create a Visitor region variable in sGTM.

variable configuration 

3. Enable the checkbox Enable region-specific settings in GA4 clients and select the Visitor region variable you created in the previous step. 

ga4 client configuration

Test region-specific tag behaviour in sGTM

  1. Open server Google Tag Manager debug mode, check Request tab, and click on GA4 client. Switch the selector “Display Variables As” to Value and check the value in the field Region. You should see the correct region.
ga4 client configuration

2. Another way is by clicking on Incoming GA4 request; in the request headers, you will see Country, Region, and City. 

ga4 client configuration

Before you begin, make sure that:

  1. There is no need to configure a custom domain/confirm first-party script serving for you if you want to use stape GEO headers power up. It will work in both cases, but setting a custom domain is recommended because it allows setting up 1st party cookies.

If you use App Engine, check that the custom domain is configured correctly.

Set up GEO header power up in stape.

  1. Open your stape account and select the sGTM container for which you want to set up GEO headers.
  2. Open the power up tab and click Use GEO headers power up.
geo header power-up by stape

Region-specific settings in server GTM

  1. Open the sGTM container and create a Visitor Region variable. 
create a visitor region variable

2. Turn on region-specific settings in the GA4 clients by enabling the checkbox Enable region-specific settings and selecting the recently created Visitor Region variable.

region-specific settings in the GA4 clients
  1. Open the web GTM container and add the Consent Mode tag template.
  2. Ensure that consent mode is enabled by Clicking Admin, Container settings, and Enable consent overview should be enabled. 
container settings

3. Create a new tag with the type Consent Mode tag. Set what type of cookies should be set for which region. The tag will check areas based on the GEO headers power-up you’ve enabled in stape. The trigger should be Consent Initialization - All Pages.

consent mode tag

4. Open tag that should listen to the region-specific consent settings and specify which cookies this tag sets. Scroll down to Consent Settings and identify the types of cookies. 

consent settings

Test region-specific tag behavior

Open GTM preview mode and trigger tag that should be using region-specific tag settings. Open the website console, go to Application -> Cookies, and check that the cookies' behavior matches the settings in the Consent Mode tag.


This blog post discussed how to set up region-specific tag behavior on the app engine, geo headers power up from Stape, and trigger consent banners using GEO header power up by Stape. This maximized efficiency and accuracy when targeting specific users in different geographic locations. 

Overall, region-specific tag behavior is a powerful tool that can help you optimize your tracking practices and ensure user privacy. Its flexibility can target specific regions or exclude certain regions as needed, which can be especially useful when dealing with requirements like consent banners. 

Tagged with:gtm server

Host your GTM server at Stape