GA 事件跟踪 + onClick="document.location.href=' [英] GA Event Tracking + onClick="document.location.href='

查看:59
本文介绍了GA 事件跟踪 + onClick="document.location.href='的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

制作我们正在开发的网站的开发人员使用以下按钮链接到 PDF 下载:

The developer who made a site we're working on has buttons linking to PDF downloads using:

<button onClick="document.location.href='doc.pdf'"> Doc Name </button>

但是,我们还需要跟踪这些事件(我们不想通过 PDF 下载来夸大浏览量),使用:

However, we also need to track events for these (we don't want to inflate pageviews with PDF downloads), using:

<button onClick="_gaq.push(['_trackEvent', 'PDFs', 'Download', 'Doc Name']);""> Doc Name </button>

那么,问题是,如何在不使两个必要的onClick 冲突"的情况下进行 GA 事件跟踪?

So, the issue is, how can I do GA event tracking without having the two requisite 'onClick's conflicting?

我正在考虑使用onMouseDown"触发 GA 事件,但这会不太准确,不是吗?

I was thinking about triggering the GA Event with 'onMouseDown,' but this would be less accurate, no?

非常感谢.

推荐答案

<button class="download-pdf" onclick="document.location.href='doc.pdf';_gaq.push(['_trackEvent', 'PDFs', 'Download', 'Doc Name']);"> Doc Name </button>

这篇关于GA 事件跟踪 + onClick=&quot;document.location.href=&amp;#39;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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