可以使用谷歌分析跟踪 div 点击
我在网站的 div 中播放视频。该视频需要点击才能播放。我想知道是否可以对父 div 应用一些分析事件跟踪,以便在 div 内单击时进行跟踪。
我知道您可以将 onClick 事件与分析一起使用,但我不太确定它是否可以应用于 div 而不是像这样的出站链接:
<a href="#" onClick="_gaq.push(['_trackEvent', 'Videos', 'Play', 'vid 1']);">Click Here</a>
有人做过这样的事情吗?我意识到这有一些缺点(用户反复单击播放/暂停)等。
谢谢。
*编辑 - 我可能应该提到我不清楚如何将 div 变成可点击事件。
假设我的 div 是 .我需要做什么才能使整个 div 成为 onClick 事件?
I have a video playing within a div on a site. The video requires a click to play. I'm wondering if it would be possible to apply some analytic event tracking tO the parent div that tracks anytime there is a click within the div.
I know you can use an onClick event with analytics, but am not quite sure if it could be applied to a div rather than, say, an outbound link like this:
<a href="#" onClick="_gaq.push(['_trackEvent', 'Videos', 'Play', 'vid 1']);">Click Here</a>
Has anybody body ever done something like this? I realize there are some downfalls to this (user repeatedly clicking play/pause) etc.
Thanks.
*Edit - I should probably have mentioned that I am unclear of how I would turn the div into a clickable event.
Say my div is . What would I need to do to make the whole div into an onClick event?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您当然可以执行以下操作:
但是:当您将 Flash 放入其中时,点击传播可能会出现问题,具体取决于您的浏览器。最好尝试一下这个库:
Google Analytics Tracking适用于 Adobe Flash 库。
You can certainly do something like this:
However: when you place flash inside, there could be issues with click propagation, depending on your browser. It is better to give this library a try:
Google Analytics Tracking for Adobe Flash Library.
或者,如果您使用的是 Google 较新的 Analytics.js 跟踪代码:
要进行测试,假设您有一个 Google Analytics 帐户并且 Analytics.js 嵌入在您的页面中,这将显示在您的 Google Analytics 仪表板中的“标准报告”> 下。 '实时'> “事件”...事件操作:单击,事件标签:My Wonderful Div
或更永久地位于
“行为”> 下“活动”
Or if you are using Google's newer analytics.js tracking code:
To test, provided you have a google analytics account and the analytics.js is embedded in your page, this will show up in your Google Analytics Dashboard under 'Standard Reports' > 'Real-Time' > 'Events'... Event Action: click, Event Label: My Wonderful Div
or more permanently under
'Behavior' > 'Events'