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

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

问题描述

谁犯了一个网站开发人员,我们正在处理的有使用按钮链接到下载PDF文件:

 <按钮的onClick =document.location.href ='doc.pdf'>文件名称< /按钮>

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

 <按钮的onClick =_ gaq.push(['_ trackEvent,PDF文件,下载,文​​件名']);>文件名< /按钮>

所以,问题是,我该怎么办GA事件跟踪,而不必在两个必要的onClick的矛盾的?

我在想触发事件GA与onmousedown事件,但这将是不准确的,不是吗?

提前非常感谢。


解决方案

 <按钮类=下载PDF的onclick =document.location.href ='doc.pdf ; _gaq.push(['_ trackEvent,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>

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>

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

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

Many thanks in advance.

解决方案

<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 ='的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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