谷歌Analyics不跟踪与AJAX生成的链接 [英] Google Analyics doesn't track links generated with AJAX

查看:145
本文介绍了谷歌Analyics不跟踪与AJAX生成的链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行一个网站,有大量会员链接。这些链接是通过AJAX加载。我希望能够跟踪这些链接出站点击。

标准的方式来使用谷歌Analytics(分析)来跟踪链接是使用pageTracker._trackPageview()函数。我已经试过这无济于事。这是我的code:

 < A HREF =<?PHP的echo $ link_loc>目标=_blank级=affiliateLink的onclick =pageTracker._trackPageview('/事件/去?');>链接文字< / A>
 

至于建议,我把我的谷歌Analytics(分析)标准跟踪code在开放body标签和上面的code之间。

有谁看到什么毛病我code?难道问题是:该链接通过AJAX加载的事实?

解决方案

  pageTracker._trackPageview('/事件/去?');
 

这应该被记录在参观/事件/去?。您的意思是记录访问 $ link_loc ?如果是这样,你必须把$ link_loc作为参数_trackPageview的一部分。你或许应该创建一个包含出站链接的只有主机和路径的字符串,减去的http:// ,并将它放入您的跟踪code

(我也想知道是否你或许应该把周围的PHP code发出的HREF引号)。

I run a website that has lots of affiliate links. These links are loaded via AJAX. I'd like to be able to track outbound clicks on these links.

The standard approach to using Google Analytics to track links is to use the pageTracker._trackPageview() function. I've tried this to no avail. Here's my code:

<a href=<?php echo $link_loc ?> target = "_blank" class="affiliateLink" onclick="pageTracker._trackPageview('/event/outgoing?');">Link Text</a>

As is suggested, I put my Google Analytics standard tracking code in between the opening body tag and the above code.

Does anyone see anything wrong with my code? Could the problem be the fact that the links are loaded via AJAX?

解决方案

pageTracker._trackPageview('/event/outgoing?');

That should be recording a visit to "/event/outgoing?". Did you mean to record a visit to $link_loc? If so, you'll have to put $link_loc as part of the argument to _trackPageview. You should probably create a string containing only the host and path of the outbound link, minus the http://, and put that into your tracking code.

(I also wonder whether you should perhaps be putting quotes around the href emitted by the php code).

这篇关于谷歌Analyics不跟踪与AJAX生成的链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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