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 2 replies, has 2 voices.

Last updated by vitoP-4 3 months, 2 weeks ago.

Assigned support staff: Rajeeb Banstola.

Author Posts
July 8, 2019 at 3:16 pm #4163927

vitoP-4

I am trying to: Setup 3 different views on Google Analytics to show me statistics for the domains I have on my website.

I tried to setup 3 different properties, but could not get the snippets added without causing a conflict.

I have tried creating 3 different views which are filtered to exclude the other 2 domains for each one.

I am not sure what to do now.

The 3 domains that are on the website are:
aleh-israel.es
aleh-israel.de
aleh.nl

Do you have any idea how to set this up on analytics using this method with WPML?

Thank you,

July 8, 2019 at 9:59 pm #4165953

Rajeeb Banstola

Hi,

Thank you for contacting WPML!

You can use the below code in header.php or footer.php of your child theme and change the tracking code based on language:

<!-- ANALYTICS TRACKING CODE -->
<?php
   // ES language
    if ( defined( 'ICL_LANGUAGE_CODE' ) && 'es' == ICL_LANGUAGE_CODE ) {
        //Just for debug, you can remove this input later
        echo('<input type="hidden" value="language active: ES">'); ?>
         
        <!-- Content for ES language here -->
          
    <?php }
    // DE language
    else if ( defined( 'ICL_LANGUAGE_CODE' ) && 'de' == ICL_LANGUAGE_CODE ) {
        //Just for debug, you can remove this input later
        echo('<input type="hidden" value="language active: DE">'); ?>
         
        <!-- Content for DE language here -->
         
    <?php }
    // NL language
    else if ( defined( 'ICL_LANGUAGE_CODE' ) && 'nl' == ICL_LANGUAGE_CODE ) {
        //Just for debug, you can remove this input later
        echo('<input type="hidden" value="language active: NL">'); ?>
         
        <!-- Content for NL language here -->
         
    <?php }
    // Just for debug, you can remove this
    else {
       echo('Something is wrong');
    }
?>
<!--/ ANALYTICS TRACKING CODE -->

Now, replace <!-- Content for NL language here --> with the tracking code you got from Google Analytics.

Let me know if this helps!

July 10, 2019 at 9:25 am #4177721

vitoP-4

Thank you, this seemed to work.

I'll let you know if I continue to have any issues,

Cheers,