[英]Using Gaq.Push to Track when a PDF is Opened
I am working on a website where there are multiple PDF's on the site. 我正在一个网站上工作,该网站上有多个PDF。 I would like to be able to track whenever a user opens a PDF, I tried doing this using the _gaq.push() method but without any luck.
我希望能够在用户打开PDF时进行跟踪,我尝试使用_gaq.push()方法执行此操作,但是没有任何运气。
Currently I have it set up like so: 目前,我已经将其设置为:
All of my links are set up this way: 我所有的链接都是以这种方式设置的:
<a href="docs/pdf.pdf" target="_blank" class="trackme" name="Download Specials">
and the code that sends the _gaq.push is pulled into every page: 发送_gaq.push的代码被拉入每个页面:
$('.trackme').click(function () {
_gaq.push(['_trackEvent', 'PDFs', 'Opened', $(this).attr("name")])
});
For some reason this has not been working and the research I have done has not really turned up any information as to what could be the issue. 由于某种原因,这没有用,我所做的研究还没有真正提供有关可能是什么问题的任何信息。 Does anyone know if there is a better way to do this or if its even possible?
有谁知道是否有更好的方法可以做到这一点?
Solved by adding 通过添加解决
_gaq.push(['_setAccount', 'AccountNumber']);
to the top 到顶部
Your code has a syntax error. 您的代码有语法错误。 You're not closing the function:
您没有关闭该功能:
It should be: 它应该是:
$('.trackme').click(function () {
_gaq.push(['_trackEvent', 'PDFs', 'Opened', $(this).attr("name")]);
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.