Skip Navigation

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

Last updated by souqalibaba 4 years, 1 month ago.

Assisted by: Bobby.

Author Posts
February 24, 2020 at 5:26 pm #5556801

souqalibaba

Tell us what you are trying to do? Add Google Analytics Tag in Another Language

Is there any documentation that you are following? https://wpml.org/forums/topic/how-to-add-the-google-analytics-for-2-languages-domains/#post-891674

Is there a similar example that we can see? we Added Google Analytics in Theme>Head....in English now just have tracking only in English Pages ...we need to add another Tags each language or can use only same Tag??

What is the link to your site? hidden link

February 24, 2020 at 8:28 pm #5557321

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Hello,

The example shown in the thread you have linked above is the correct way to add a different Tracking Code to get google analytics report separately for each language.

https://wpml.org/forums/topic/how-to-add-the-google-analytics-for-2-languages-domains/#post-891674

The code uses an IF Else statement for which you need to added your language code and then within it add your GA Tag for each language.

Each language should use a separate script.

February 24, 2020 at 9:44 pm #5557569

souqalibaba

Hi Bobby..Thank`s for interest ....

yes but in this page say:

--------------------------------
You can try the following code:
- Please modify the ICL_LANGUAGE_CODE lines according to your installed languages.
- See table at WPML -> Languages --> Edit languages
----------------------------------

in my WPML not found Edit languages where exact to Add this code ..... you can see Attachments

Thank`s

wpml2.jpg
wpml1.jpg
February 24, 2020 at 10:27 pm #5557661

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

See the code below, it uses an If Else statement utilizing the ICL_LANGUAGE_CODE, you change your CODE with the corresponding code to your active languages.

Your language codes are 'ar' , 'en', 'tr'

The code below is designed for only 2 different Google Analytics code, are you comfortable with changing the code? Please note that we cannot provide assistance with custom work but i can help you place the Google Analytics code properly.

Please provide me with the 3 scripts for each language, each language needs its own.

<?php if(ICL_LANGUAGE_CODE=='en'){?>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
   
ga('create', 'UA-326103-28', 'auto');
ga('send', 'pageview');
   
</script>
<?php } elseif(ICL_LANGUAGE_CODE=='nl'){?>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
   
ga('create', 'UA-326103-14', 'auto');
ga('send', 'pageview');
   
</script>
<?php } ?>
February 26, 2020 at 7:58 pm #5574131

souqalibaba

Hi Bobby Thank`s for help

i Add gta google analytics in theme header as attachment..

must replace code with GTA -A..... -1 code ?

Untitled - 1.jpg
February 26, 2020 at 8:08 pm #5574173

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Yes you have to replace the above GA script with your own

February 26, 2020 at 9:37 pm #5574461

souqalibaba

Hi sir we tested ...work fine .....very Thankful ....for help

Thank`s

Best regards

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.