向站点添加事件跟踪以进行 PDF/Microsoft Word 下载

发布于 2024-12-07 17:23:25 字数 485 浏览 1 评论 0原文

我在设置事件跟踪时遇到一些困难。我有一个网站,人们可以下载各种内容的 PDF 和 Word 文档。我像这样插入了事件跟踪:

<a href=files/8399039122.pdf onClick='_gaq.push(['_trackEvent', 'downloads', 
'all', 'nofilter']);' >File #1</a>

<a href=files/8329384939.doc onClick='_gaq.push(['_trackEvent', 'downloads',
 'all', 'nofilter']);' >File #2</a>

但是,四天后数据仍然没有显示在我的分析配置文件中。难道是我安装错了?另外,我是否需要将 _gaq.push(['_trackEvent', 'downloads', 'all', nofilter]);' 添加到页面标题中的分析脚本中?

I am having some difficulty setting up event tracking. I have a website where people can download PDFs and Word docs of various content. I inserted the event tracking like so:

<a href=files/8399039122.pdf onClick='_gaq.push(['_trackEvent', 'downloads', 
'all', 'nofilter']);' >File #1</a>

<a href=files/8329384939.doc onClick='_gaq.push(['_trackEvent', 'downloads',
 'all', 'nofilter']);' >File #2</a>

However, after four days data is still not showing up on my analytics profile. Did I install this wrong? Also, do I need to add the _gaq.push(['_trackEvent', 'downloads', 'all', nofilter]);' to the analytics script in the header of my page?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

三生殊途 2024-12-14 17:23:25

看起来这是您使用单引号(未正确嵌套)。试试这个:

<a href="files/8399039122.pdf" onClick="_gaq.push(['_trackEvent', 'downloads', 'all', 'nofilter']);" >File #1</a>

<a href="files/8329384939.doc" onClick="_gaq.push(['_trackEvent', 'downloads', 'all', 'nofilter']);" >File #2</a>

将整个 onClick 用双引号括起来。并且,链接的路径 (href) 也应该被引用。

延迟 onclick 而不使用 target="blank"

<a href="pdfs/my-file.pdf" onclick="var that=this;_gaq.push(['_trackEvent,'Download','PDF',this.href]);setTimeout(function(){location.href=that.href;},200);return false;">Download my file</a>

Looks like it's your use of single quotes (not nested properly). Try this:

<a href="files/8399039122.pdf" onClick="_gaq.push(['_trackEvent', 'downloads', 'all', 'nofilter']);" >File #1</a>

<a href="files/8329384939.doc" onClick="_gaq.push(['_trackEvent', 'downloads', 'all', 'nofilter']);" >File #2</a>

Wrap the entire onClick in double quotes. And, the path to your links (href) should be quoted as well.

To delay the onclick without using target="blank"

<a href="pdfs/my-file.pdf" onclick="var that=this;_gaq.push(['_trackEvent,'Download','PDF',this.href]);setTimeout(function(){location.href=that.href;},200);return false;">Download my file</a>
无敌元气妹 2024-12-14 17:23:25

解决此问题的另一种方法是将 target="_blank" 添加到 标记:

<a href="files/2117802037.pdf" onclick="_gaq.push(['_trackEvent', 'downloads', 'all', 'nofilter']);" target="_blank">File #1</a>
<a href="files/8329384939.doc" onclick="_gaq.push(['_trackEvent', 'downloads', 'all', 'nofilter']);" target="_blank">File #2</a>

Another way to resolve this issue is to add target="_blank" to the <a> tag:

<a href="files/2117802037.pdf" onclick="_gaq.push(['_trackEvent', 'downloads', 'all', 'nofilter']);" target="_blank">File #1</a>
<a href="files/8329384939.doc" onclick="_gaq.push(['_trackEvent', 'downloads', 'all', 'nofilter']);" target="_blank">File #2</a>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文