Updating visitor language, sending multi-language notifications
If your website uses one domain with several languages, and you want to send the same Web Push Notification to everyone, but with each subscriber receiving the message in his own language, read more below.
For each visitor you can manually set his language setting by customizing MaxTraffic tracking code. For example - if a visitor is viewing your website in Estonian language, you can set "Estonian" as his language, and later - if you send a Web Push notification to your subscribers and also add an Estonian translation - then this specific visitor will receive the Estonian version of your message.
1. Get the language code
To get started, please check https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes - you must use the language code from column "639-1" for the language you want to set.
For example:
- lv if visitor is using websites version in Latvian language
- et if visitor is using websites version in Estonian language
- en if visitor is using websites version in English language
2. Update tracking code
The standard tracking code looks like this (where 123 is your website ID):
<script>
window.mt=window.mt||function(){(mt.q=mt.q||[]).push(arguments)};mt.l=+new Date;
mt('create', 123);
</script>
<script async src="//cdn.mxapis.com/mt.js"></script>
If your website visitor is using Estonian version, you can update his language setting with this code:
<script>
//set language setting to Estonian
mt("setLanguage", "et");
</script>
Language customization code has to be executed after the main tracking code, so both codes combined will look like this:
<script>
window.mt=window.mt||function(){(mt.q=mt.q||[]).push(arguments)};mt.l=+new Date;
mt('create', 123);
</script>
<script async src="//cdn.mxapis.com/mt.js"></script>
<script>
//set language setting to Estonian
mt("setLanguage", "et");
</script>
This language customization code can be executed in each pageview and if visitor switches between several languages (for example, from English to Estonian, then to German, then to Spanish, etc), then our system will save the last language used for that specific visitor.
And when you send a Push Notification - if you have added a translation for the language that was set to this specific visitor, then he will receive his language version of message, if not - then he will receive the default message.
3. Send the same message in several languages at once
When you are sending a new notification, you can click "Add Language" button:
Then select to which languages you want to translate it, for example - lets add Russian language:
And then you can translate the message in Russian language as well:
And when the message is sent - then for those subscribers, whose language setting will be set as "ru" (Russian), they will receive the Russian version of this message, but all other subscriber will receive the default version of your message.
Of course - if you have more than 2 languages in your website, then you can translate your message to as many languages as you like, just add more of them when you click "Add language".
Why translate messages, if you can create visitor segments by country?
Some of our clients are using custom segments that are based on visitors country. Of course, that can also be a way how to group subscribers and send them specific messages, but in our opinion there are several advantages of translating messages:
- For each language you can not only translate the content, but also set custom links and UTM tags. That way, for example, you can send the Russian speaking visitor directly to the Russian version of your website.
- You don't have to create many segments based on visitor's country and send many messages one after another. The same message can be sent only once and with as many translations as you wish.
- If you customize the tracking code and set the language setting for your subscribers - that will work more precise than grouping them by countries, because in 1 country many languages can be used, and there can be cases where an Estonian lives in Germany, etc.