__utm Cookie的Google Analytics(分析)字符编码 [英] Google Analytics Character encoding of __utm cookies

查看:420
本文介绍了__utm Cookie的Google Analytics(分析)字符编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想弄清楚GA在保存Cookie时使用的编码。例如,当设置utm_source参数时,我可以使用非西方字符,并且它们在GA报告中显示得很好。但是,如果我查看__utmz cookie,它不匹配utm_source参数的值,而是似乎以某种方式编码,我知道有URL编码,但这是不同的。

I'm trying to figure out what encoding GA uses when it saves cookies. For example, I can use non-western characters when setting the utm_source parameter and they show up fine in the GA reports. However, if I look at the __utmz cookie, it does not match the value for utm_source parameter, instead is seems to be encoded somehow, I know there is URL encoding, but this is something different.

示例:

1)访问www.example.com?utm_source=ХЦЧШЩЬЫЪЭЮЯ

1) Visit www.example.com?utm_source=ХЦЧШЩЬЫЪЭЮЯ

2)查看cookies。 __utmz cookie保存给utm_source param的任何值。它包含值似乎被编码的值。

2) View cookies. The __utmz cookie saves whatever value was given to utm_source param. It contains the value ХЦЧШЩЬЫЪЭЮЯ which seems to be encoded.

3)点击网站上的查看GA报表。

3) click around on website then view GA reports. You see ХЦЧШЩЬЫЪЭЮЯ as visit source, which is correct.

我试图写一些JavaScript来读取__utmz cookie并将其保存在Google App Engine数据存储中,然后成功地在HTML页面中显示它。我试过所有类型的编码(utf-8)解码(utf-8)解决方案,但似乎没有什么工作。我假设这是因为我在设置cookie时没有使用原始编码。

I'm trying to write some JavaScript that will read the __utmz cookie and save it in a Google App Engine Datastore then successfully display it in an HTML page. I've tried all types of encode(utf-8) decode(utf-8) solutions but nothing seems to work. I assume this is because I don't have the original encoding used when setting the cookie.

推荐答案

使用的编码是UTF- 8。当ХЦЧШЩЬЫЪЭЮЯ是UTF-8编码,然后UTF-8编码值的字节显示为好像他们是窗口-1252编码,你得到¯¥Ð|ЧÐÐÐЫЪÐиЯ 。例如,第一个字符X,西里尔字母大写字母ha,是U + 0425,当UTF-8编码时是字节0xD0 0xA5。当这些字节被解释为windows-1252(或ISO-8859-1)编码字符数据时,它们意味着U + 00D0 U + 00A5,即Ð¥。

The encoding used is UTF-8. When ХЦЧШЩЬЫЪЭЮЯ is UTF-8 encoded and then then the bytes of the UTF-8 encoded value are displayed as if they were windows-1252 encoded, you get ХЦЧШЩЬЫЪЭЮЯ. For example, the first character X, cyrillic capital letter ha, is U+0425, which is bytes 0xD0 0xA5 when UTF-8 encoded. When these bytes are interpreted as windows-1252 (or ISO-8859-1) encoded character data, they mean U+00D0 U+00A5, i.e. Ð¥.

这篇关于__utm Cookie的Google Analytics(分析)字符编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆