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 thread is resolved. Here is a description of the problem and solution.

Problem: I have a bilingual website. How can I get Google Analytics report separately for each language/domain?

Solution: See the code and the solution in the following post: https://wpml.org/forums/topic/how-to-add-the-google-analytics-for-2-languages-domains/#post-891674

This topic contains 4 replies, has 3 voices.

Last updated by Vincenzo 2 years, 5 months ago.

Assigned support staff: Vincenzo.

Author Posts
May 26, 2016 at 2:32 pm #891011

Muriel

I am trying to: add google analytics code for a bilingual website.
The NL/EN website is on a single wordpress installation which uses wpml.
The different languages uses different domains (ghyczy.com and ghyczy.nl).
How can I get google analytics report separately for each language?

URL of (my) website where problem appears:(ghyczy.com and ghyczy.nl)

I have tried to follow this link: https://wpml.org/forums/topic/google-analytics-for-two-languages/

But no idea how to implement it.

The code now is:

<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>

But I need to add UA-326103-14 for hidden link, as the other UA is for hidden link.

Help please?

May 27, 2016 at 12:04 pm #891674

Vincenzo
Supporter

Languages: English (English ) Italian (Italiano )

Timezone: Europe/Rome (GMT+02:00)

Hello, thank you for contacting WPML Support!
I will take care of your ticket

❌ Before proceeding please make a backup of the files that you are going to modify! ❌

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

<?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 } ?>
May 27, 2016 at 3:16 pm #891822

Muriel

I think that did the trick! 🙂
Thank you!

April 21, 2017 at 10:57 am #1258907

yasinE

I also have these issue but i could not found it how ...

April 21, 2017 at 11:02 am #1258913

Vincenzo
Supporter

Languages: English (English ) Italian (Italiano )

Timezone: Europe/Rome (GMT+02:00)

@yasine

This ticket is closed.

Please open a new ticket and we will gladly help you.

Thank you