Google分析跟踪pdf下载 [英] Google analytics track pdf downloads

查看:104
本文介绍了Google分析跟踪pdf下载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在这里读到它是如何完成的 http://support.google.com/googleanalytics/bin/answer.py?hl=zh_CN& ;答案= 55529



但我试着在我的链接上实现它,并且自从我做了几个星期后,我看不到它在哪里已经出现。 (我知道我点了几次)



以下是我用过的代码。



对于外部链接

 < a onclick =javascript:_gaq.push(['_ trackPageview','/ external-链路/ www.somesite.com']); href =http://www.somesite.com/title =外部链接> www.somesite.com< / a> 

对于pdf文件

 < a onclick =javascript:_gaq.push(['_ trackPageview','/pdfs/test.pdf']); href =http://www.site.com/pdfs/test.pdf>下载并完成a将您的super转换为Cbus表单< / a> 

我在网页上有分析数据,但似乎无法跟踪。



有没有人得到这个工作?任何帮助,将不胜感激。



谢谢

解决方案

在Chrome浏览器中使用开发人员工具或Firefox& Firebug并检查控制台是否有javascript错误?



另外,您可能想使用事件追踪而不是浏览量,如 http://code.google.com/apis/analytics/docs/tracking/eventTrackerGuide.html



在这种情况下,您的代码看起来就像

 < a onclick =_ gaq.push(['_ trackEvent','File','Download','/pdfs/test.pdf']); href =http://www.site.com/pdfs/test.pdf>下载并完成a将您的super转换为Cbus表单< / a> 

需要注意的一点是Google Analytics的工作原理是请求跟踪像素。如果您在跟踪像素请求完成之前离开当前页面,您将看不到分析数据。我已经获得了很好的结果,其中包括以下变体:

 < script type =text / javascript> 
函数trackLink(link){
_gaq.push(['_ trackEvent','Link','Click',link.href])
if(_blank== link.target )返回true;
setTimeout('document.location =''+ link.href +'',150);
返回false;
}
< / script>

总之,除非链接在新窗口中打开(`_blank== link.target) ,等待150毫秒后自己处理到新的URL。


I was wondering if anyone has gotten file download and external link tracking with google analytics working.

I read here how its done http://support.google.com/googleanalytics/bin/answer.py?hl=en&answer=55529.

But I tried implementing it on my links and its been a couple weeks since I did it and I can't see where it has shown up. (I know i've clicked it a couple of times)

Here is the code I have used.

For an external link

<a onclick="javascript: _gaq.push(['_trackPageview', '/external-link/www.somesite.com']);" href="http://www.somesite.com/" title="External link">www.somesite.com</a>

For the pdf file

<a onclick="javascript: _gaq.push(['_trackPageview', '/pdfs/test.pdf']);" href="http://www.site.com/pdfs/test.pdf">Downland and complete a Transfer your super into Cbus form</a>

I have analytics on the page but it doesn't seem to be tracking.

Has anyone gotten this working? Any help would be appreciated.

Thanks

解决方案

Have you tried looking at your page either in Chrome with the developer tools or Firefox & Firebug and check the console for javascript errors?

Also, you may want to use event tracking instead of pageviews, like at http://code.google.com/apis/analytics/docs/tracking/eventTrackerGuide.html

In that case, your code would look something like

<a onclick="_gaq.push(['_trackEvent', 'File', 'Download', '/pdfs/test.pdf']);" href="http://www.site.com/pdfs/test.pdf">Downland and complete a Transfer your super into Cbus form</a>

Something to be aware of is that Google Analytics works by requesting a tracking pixel. If you leave the current page before the tracking pixel request has completed, you won't see the analytics data. I've had good results with variations of the following:

<script type="text/javascript">
function trackLink(link) {
    _gaq.push(['_trackEvent', 'Link', 'Click', link.href])
    if ("_blank" == link.target) return true;
    setTimeout('document.location = "' + link.href + '"', 150);
    return false;        
}
</script>
<a onclick="return trackLink(this);" href="http://www.somesite.com/" title="External link">www.somesite.com</a>

In brief, unless the link opens in a new window (`_blank" == link.target), handle going to the new URL ourselves after waiting 150 ms.

这篇关于Google分析跟踪pdf下载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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