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>