谷歌分析自动标记出站链接

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了谷歌分析自动标记出站链接相关的知识,希望对你有一定的参考价值。

This will automatically tag external links and prefix the URL with '/outgoing' for tracking in Google Analytics. The pageTracker is assumed to be added to the page elsewhere in the markup. By default it is applied to all links contained in the BODY tag, excluding those with the class 'noAutoLink.' This snippet is not an original work of mine, but I do not know its author.
  1. <script type="text/javascript">
  2. $(document).ready(function() {
  3. $('body a').filter(function() {
  4. var theHref = this;
  5.  
  6. if (theHref.hostname && theHref.hostname !== location.hostname) {
  7. $(theHref).not(".noAutoLink").attr('target', '_blank').bind('click keypress', function(event) {
  8. var code = event.charCode || event.keyCode;
  9.  
  10. if (!code || (code && code == 13)) {
  11. if (pageTracker) {
  12. var fixedLink = this.href;
  13.  
  14. fixedLink = fixedLink.replace(/https?://(.*)/, "$1");
  15. fixedLink = '/outgoing/' + fixedLink;
  16. pageTracker._trackPageview(fixedLink);
  17. }
  18. };
  19. });
  20. };
  21. });
  22. });
  23. </script>

以上是关于谷歌分析自动标记出站链接的主要内容,如果未能解决你的问题,请参考以下文章

javascript 出站链接跟踪 - 谷歌分析jquery / javascript

带有标记的Android谷歌地图片段

如何更改谷歌地图标记上方的标题和片段设计

InfoWindow中的Android Google地图摘要自动更新

CPNtools协议建模安全分析---实例变迁标记

不同外部链接的谷歌地图标记点击功能问题