Hello,
I am trying to do something similar, but with language and locale.
What exactly does the user.header('accept-language') get? usually the accept language has locale and factor weighting included. Accept-Language - HTTP | MDN
for example if i wanted to create a profile script differentiating england from united states for english, i would need to parse the language and locale. would the user.header("accept-language") give me "en-gb" or "en-us"?
Does using console.log work for debugging these scripts? It is difficult to use the built in target parameters without know exactly what it provides.
any help would be much appreciated!
Gyles Fohl
Solved! Go to Solution.
Hi Gyles,
Thanks for your questions! Using console.log is not an option because this is not js that gets executed in the page, it is js that is executed server side, when the mbox call comes in. The user.header ("accept-language") would give you "en-gb" or "en-us" because it captures whatever the browser sends as its language header. In most cases you should get the en-gb or en-us coming though.
Warmly,
Amelia
Hi Gyles,
Thanks for your questions! Using console.log is not an option because this is not js that gets executed in the page, it is js that is executed server side, when the mbox call comes in. The user.header ("accept-language") would give you "en-gb" or "en-us" because it captures whatever the browser sends as its language header. In most cases you should get the en-gb or en-us coming though.
Warmly,
Amelia
Great, thanks for the info about the accept-language. Is there a way to debug profile scripts?
Thanks,
Gyles
Views
Replies
Total Likes
Hi Gyles,
There is no way to debug profile scripts, though you can try to write out the value of the profile script in an Offer using token replace and then view the value of the profile script, which may be helpful.
Warmly,
Amelia
Hi Gyles,
Just to follow up on an alternative (and new best practice) for getting visitor language --
Using user.header('accept-language') is no longer best practice now that Browser->Language and Site Pages->HTTP Header->Accept-Language are both UI options in the Audience builder:
User.header('accept-language') = the latter, and could do the same differentiation. User.header('accept-language') is no longer necessary, except for maybe in a token replace.
Hope this was helpful!
Views
Replies
Total Likes
Hello,
This does not address the original question unfortunately. I had tried going this route originally but because those options are so limited it was of not helpful.
There are only about 10 languages, for example there is no Italian or traditional chinese. Also, the language options do not distinguish locale, which accept-header does. from original post: "en-gb" or "en-us".
I would recommend adding more languages and options for locale.
Thanks!
Views
Replies
Total Likes
Hi Gyles,
Thanks for sharing this experience with the community - appreciate this suggestion! The good thing about discussing it here is that you're probably not the only one that might be interested in this!
To that end, would you mind posting this as a "New Idea" using the "Submit an Idea" link on the right of the page (orange lightbub icon)? This way, other community members can vote up on this idea, and it can then be suggested to the product team.
Thanks again!
Warmly,
Amelia
Views
Replies
Total Likes
Just a warning to anyone using the language rules when creating audiences:
When you choose Browser - English for example, it won't consider US English to be English, because it doesn't include locale settings when determining language.
So, setting browser - english only works for "EN", but not for "EN-US" or "EN-GB", which basically makes it useless.
Gyles
Views
Replies
Total Likes
Running into the same issue we solved that by using the Accept language setting in Adobe target
Site Pages: HTTP Header Accept-Language startsWith
zh
above to target all Chinese language packages. This will also trigger with zh_TW, zh, zh-CN,... a.s.o
however this method seems to be not able to take the preferred language weighting into account (so the `startsWith` is not really respected and behaves like `contains`)
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies