如何使用Google Analytics跟踪下载情况? [英] How to use Google Analytics to track downloads?

查看:124
本文介绍了如何使用Google Analytics跟踪下载情况?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网站,里面有.tar.gz,.zip和.dmg文件。我需要使用谷歌分析来追踪下载次数。我听说我可以使用onclick =pageTracker._trackPageview('/ file_name.file_extension')作为页面上的a标签。
我不清楚file_name.file_extension对应的是什么。我需要使用一些额外的脚本?

解决方案


我不清楚
file_name.file_extension对应


您的示例 onclick =pageTracker._trackPageview(' /file_name.file_extension')将该链接的每次点击记录为 file_name.file_extension 的页面视图。



您可以编辑 file_name.file_extension 来做任何你想要的。它只是传递给Google Analytics的网页浏览量的名称,并且会显示在分析报告中。另外,是否需要使用一些额外的
脚本?


否,添加上面的 onlick

属性到您想要跟踪的每个链接就足够了。 analytics / bin / answer.py?hl = en& answer = 55529rel =nofollow noreferrer>请参阅此处以供参考。希望有帮助。



编辑: 我以为你知道你需要一般Google Analytics(分析)脚本可以实现此目的(感谢瑞恩在澄清的评论中)。该脚本如下所示,但在 UA-XXXXXX-X 中包含您的Google Analytics帐号代替X:

 < script type =text / javascript> 
var gaJsHost =((https:== document.location.protocol)?https:// ssl。:http:// www。);
document.write(unescape(%3Cscript src ='+ gaJsHost +google-analytics.com/ga.js'type ='text / javascript'%3E%3C / script%3E));
< / script>
< script type =text / javascript>
尝试{
var pageTracker = _gat._getTracker(UA-XXXXXX-X);
pageTracker._trackPageview();
} catch(err){}
< / script>

要获得脚本,您需要一个 Google Analytics(分析)帐户。登录到您的帐户后,添加新的网站个人资料后,您将获得一段Javascript代码(使用您的帐户号码)以包含在您要跟踪的每个网页中,以及说明。这应该足以让你开始,但让我知道,如果我可以澄清任何事情。



编辑2:



正如评论中指出的那样,我错误地发布了最新的异步版Google Analytics脚本,它与 _trackPageview 不兼容。我编辑了我的答案,以包含您要使用的传统脚本。 请参阅此处了解更多信息。


I have a website where I have .tar.gz, .zip and .dmg files. I need to track the number of downloads using google analytics. I heard that I can use onclick="pageTracker._trackPageview('/file_name.file_extension') for the "a" tags on the page. I'm not clear what the file_name.file_extension corresponds to. Also, do I need to use some additional scripts?

解决方案

I'm not clear what the file_name.file_extension corresponds to.

Your example onclick="pageTracker._trackPageview('/file_name.file_extension') logs every click on that link as a page view for file_name.file_extension.

You can edit file_name.file_extension to be whatever you want. It is simply the name of the "page view" that gets passed to Google Analytics and is what will show up in your analytics reports.

Also, do I need to use some additional scripts?

No, adding the above onlick attribute to each link you want tracked will be enough.

See here for reference. Hope that helps.

Edit:

I assumed you knew you needed the general Google Analytics script for this to work (Thanks to Ryan in the comments for clarifying). The script looks like the following, but contains your Google Analytics account number in place of the X's in UA-XXXXXX-X:

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try{
var pageTracker = _gat._getTracker("UA-XXXXXX-X");
pageTracker._trackPageview();
} catch(err) {}
</script>

To obtain the script, you'll need a Google Analytics account. Once signed into your account and after adding a new "Website Profile", you'll be given a snippet of Javascript (using your account number) to include in each page you want tracked, along with instructions. That should be enough to get you started, but let me know if I can clarify anything.

Edit 2:

As pointed out in the comments, I erroneously posted the latest, asynchronous version of the Google Analytics script which is actually incompatible with _trackPageview. I've edited my answer to include the "traditional" script that you'll want to use. See here for more info.

这篇关于如何使用Google Analytics跟踪下载情况?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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