Skip to content Skip to sidebar

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 1 reply, has 0 voices.

Last updated by Nicolas V. 3 months, 2 weeks ago.

Author Posts
April 7, 2025 at 9:07 pm #16906399

coltW

Background of the issue:
I am trying to set up Google Analytics to track multiple languages on a site under development using WPML. I found a related question on the WPML forums.

Symptoms:
The answer to the question on the WPML forums is not visible.

Questions:
Can you provide the information from the WPML forum topic on setting up Google Analytics to track different languages?

April 8, 2025 at 8:20 pm #16910894

Nicolas V.
Supporter

Languages: English (English ) French (Français )

Timezone: America/Lima (GMT-05:00)

Hi,

Welcome to the WPML support forum. Thanks for contacting us.

While waiting for one of my colleagues to help with this ticket, and based on what you've described, allow me to walk you through some initial debugging steps.

1. Same Google Analytic for all languages
If you're using language folders in your URL structure (e.g., domain.com/en/, domain.com/es/), you can track all website traffic under a single Google Analytics property. Google Analytics allows you to filter or create views based on subdirectories. For example, you can create a filtered view to track only Spanish visitors by targeting /es/.
Refer to the official Analytics documentation on how to set up views.

2. Different Google Analytics accounts
If you prefer to use a separate tracking ID for each language, you can implement a custom solution using the code below:

 
add_action( 'wp_head', function(){
$my_current_lang = apply_filters( 'wpml_current_language', NULL );
if ( $my_current_lang == 'fr' ){ ?>
<!-- Tracking code for FR language here -->

<?php } elseif ( $my_current_lang == 'en' ){ ?>
<!-- Tracking code for EN language here -->

<?php } 
});

If that doesn't answer you question, could you please provide more details about what you're trying to achieve?

Nico

The topic ‘[Closed] Tracking multiple languages with Google Analytics’ is closed to new replies.