Last updated: 4 January 2025

The best GA4 setup for multilingual websites

Nick van Maaren
Freelance Ads & Analytics expert

3 types of multilingual websites:

Multilingual functionality is generally implemented in one of the following three ways:

  1. Based on subfolders (e.g., https://measurebase.com/nl/ & https://measurebase.com/fr/).
  2. Based on subdomains (e.g., https://nl.measurebase.com & https://fr.measurebase.com).
  3. Based on multiple top-level domains (e.g., https://measurebase.nl & https://measurebase.fr).

In this blog, I will explain the best GA4 setup for each option.

The best setup for each of the 3 options

My advice is to keep your setup as simple as possible and use the minimum number of properties. Avoid creating separate properties or data streams for each language, as this adds unnecessary complexity to maintaining the GA4 setup. If you want to analyze the data of just one of the languages, you can use the Page URL (when the setup is based on subfolders) or the Page hostname (when the setup is based on subdomains or top-level domains).

Multilingual setup based on Subfolders
When using subfolders, the setup is straightforward. Use a single Google Tag Manager (GTM) container to load one property. Cross-domain tracking is not required for subdomains in GA4. However, sending the page_language parameter might still be a good idea.

Multilingual setup based on Subdomains
Using subdomains is similarly straightforward in GA4. Use one or more GTM containers to load one property. Cross-domain tracking is not required for subdomains in GA4. However, sending the page_language parameter might still be a good idea.

Multilingual setup based on Multiple Domains
For multiple domains, the setup is more complex. Use one or more GTM containers to load one property, and make sure to set up cross-domain tracking. Sending the page_language parameter might be a good idea.

Setting up cross-domain tracking

Google Analytics uses cookies to track users. By default, GA can only place cookies on the domain where the script is loaded. For subdomains, cross-domain tracking is not needed, but for multiple domains, it is essential.

To set up cross-domain tracking:

  • Go to Admin > Data Streams in Google Analytics.
  • Click on the data stream for which you want to configure cross-domain tracking.
  • Select Configure tag settings.
  • Under Settings, click Show all.
  • Select Configure your domains.
  • Click Add condition and choose the desired match type, e.g., “Contains”.
  • Enter the domain name under Domain (e.g., example.nl). Repeat for all other domains.
  • Ensure the same Google Analytics tracking ID is used across all domains.

Adding the language parameter

For all three setups, it’s important to add a language parameter. This helps track traffic per language in GA4 and tools like Looker Studio.

Step 1: Create a Regex Table

  • Open Google Tag Manager and navigate to Variables.
  • Create a new variable and select Regex Table.
  • Add rows with patterns and outputs:
    • For subfolder setups, use Page URL as the input variable.
    • For subdomain setups, use Page Hostname as the input variable.
    • For multi-domain setups, use Page Hostname as the input variable.
  • Use simple regex patterns, e.g., /en/ or /fr/|/be-fr/ for the Input. You can test your Regex pattern on Regex101.com.
  • As the Output type out the language, e.g. “French” or “FR”.
  • Set a default value for cases where no conditions are met:
    • If the original language is not included in the Regex pattern because it deviates from the rest of the languages, set the original language as the default: e.g. “English”. This can be the case when using subfolders or subdomains and the original language is not in a subfolder or subdomain.
    • If the original language is included in the Regex pattern, you can set this value to e.g. “not set” or “No language selected”.
  • Click on Advanced Settings and uncheck both Full Matches Only and Enable Capture Groups and Replace Functionality.
  • Save the variable.

Step 2: Add the Regex Table Variable to the GA4 Configuration Tag

  • Go to Google Tag Manager.
  • Navigate to Tags.
  • Open the GA4 configuration tag.
  • Add a new parameter under Fields to set.
  • Enter the language parameter name under Field Name (e.g., page_language) and select the Regex Table Variable under Value.
  • Save the tag.

Step 3: Add the Regex Table variable to all Event tags

  • Open the GA4 event tag where you want to add the language parameter.
  • Add a new parameter under Event Parameters.
  • Enter the parameter name (e.g., page_language) and select the created Regex Table Variable under Value.
  • Save the tag.

Step 4: Create a custom dimension for “page_language” in GA4

  • Go to Google Analytics and select the correct GA4 property.
  • Navigate to Configure > Custom Definitions.
  • Click Create custom dimensions.
  • Enter a dimension name (e.g., page_language).
  • Enter the exact name of the language parameter under Event parameter (e.g., page_language).
  • Save the dimension.

Testing the new setup

Test the setup using GTM’s Preview function and the DebugView in GA4. Once everything is correctly configured, publish the changes.

The custom dimension is now available in GA4 and can also be used in tools like Looker Studio. In Looker, for example, you can add a control that uses the custom language dimension to filter the dashboard.

Learning track: How to set-up GA4?

This article is part of the learning track: "How to set-up GA4?" In this step-by-step guide, we’ll walk you through the entire process of setting up your GA4 tracking. You don't need any prior experience with setting up GA4 to follow these steps. Explore the other articles in this learning track below.

Discover this track

Join the community

Level up your analytics skills in our free Discord community.

Join MeasureBase
This site is registered on wpml.org as a development site. Switch to a production site key to remove this banner.