谷歌Analytics(分析)发出的休息在Angular.js项目链接 [英] Google Analytics breaks emitted links in Angular.js project

查看:105
本文介绍了谷歌Analytics(分析)发出的休息在Angular.js项目链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们的项目中Angular.js,散发出本地化的内容,当我面对一个问题,那就是,如果有局部< A HREF =>在本地化HTML字符串-s,谷歌分析打破它们。

在具体地,它的变化

 < A HREF =htt​​ps://my-site.com/#!/path/to/somewhere>

成类似

 < A HREF =htt​​ps://my-site.com/?_ga=1.42271222.21175886562.1384128808#!/path/to/somewhere>

就在那一刻我点击链接(带有鼠标按钮)。当检查DOM,我可以看到,我还没有触及的链接是完全有效的,而我的链接右键单击选择检查弹出式菜单项在上面提到的方式打破了。

UPD:问题就解决了​​。
解决方法:使用相对链接尽可能。如果你正在调试你的网站,其地址从真实的不同,所以绝对链接到真正的网站地址为(显然)在调试版本考虑跨域。

在特别地,上述连结

 < A HREF =htt​​ps://my-site.com/#!/path/to/somewhere>

应该已更改为

 < A HREF =/#/路径/要/地方!>


解决方案

这看起来就像你正在使用跨域与GA(跟踪<一个href=\"https://developers.google.com/analytics/devguides/collection/analyticsjs/cross-domain#linkerparam\"相对=nofollow> _ GA是当链接域中所使用的参数,它承载了客户端ID)。有没有在GA code启用任何装饰/ autolinking的功能呢?我认为天然气autolinking功能将不承认锚作为URL路径的一部分,并在域和锚之间插入链接参数。

如果您需要跨域跟踪,你可以尽量不使用自动链接,而是手动检索客户端ID,并追加到URL的末尾。

如果您不使用跨域跟踪你应该张贴您的分析相关的code,可能会有一些错误配置。

In our Angular.js project, when emitting localized content I face a problem, that is, in case there are local <a href=>-s in the localized HTML strings, google analytics breaks them.

In particular, it changes

<a href="https://my-site.com/#!/path/to/somewhere">

into something like

<a href="https://my-site.com/?_ga=1.42271222.21175886562.1384128808#!/path/to/somewhere">

right at the moment I click the link (with either mouse button). When inspecting the DOM, I can see that the links I haven't yet touched are perfectly valid, while the link I right-clicked to select the "Inspect" popup menu item is broken in a way mentioned above.

UPD: The problem is solved. Solution: use relative links whenever possible. If you are debugging your site, its address differs from the real one, so an absolute link to the real site address will be (obviously) considered cross-domain in the debug version.

In particular, the above link

<a href="https://my-site.com/#!/path/to/somewhere">

should have been changed to

<a href="/#!/path/to/somewhere">

解决方案

That looks like you are using cross domain tracking with GA (_ga is the parameter that is used when "linking" domains, it carries over the client id). Are there any decorators/autolinking functions enabled in the ga code ? I think Gas autolinking functions would not recognize the anchor as part of the url path and insert the linking parameter in between the domain and the anchor.

If you need cross domain tracking you could try not to use automatic linking and instead retrieve the client id manually and append it to the end of the url.

If you are not using cross domain tracking you should post your analytics-related code, there might be something misconfigured.

这篇关于谷歌Analytics(分析)发出的休息在Angular.js项目链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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