Google Analytics事件 - 点击一个div

时间:2016-03-03 14:34:17

标签: javascript google-analytics

我刚刚在我的分析代码中添加了这一简单的行:

setTimeout("ga('send','event','Adjusted bounce rate','page visit 20 seconds or more')",20000);

所以我会监控所有留在我页面上超过20秒的用户。

现在我想添加一个事件,让我知道用户是否点击过div。

我该怎么做?

解决

<div id=MYDIV onclick="ga('send', 'event', 'Click on the menu icon', 'Click');">

1 个答案:

答案 0 :(得分:2)

一点点修复:

#  2.  you can add dependencies to your leaflet map
#  this mechanism will smartly handle duplicates
#  but carries a little more overhead
str(m$dependencies)  # should be null to start
# 
m$dependencies <- list(
  htmlDependency(
    name = "font-awesome"
    ,version = "4.3.0"
    # if local file use file instead of href below
    #  with an absolute path
    ,src = c(href="http://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css")
    ,stylesheet = "font-awesome.min.css"
  )
)

m

使用JQuery:

setTimeout(function(){
  ga('send','event','Adjusted bounce rate','page visit 20 seconds or more');
},20000);

HTML:

$('#my-div').click(function(){
  ga('send','event','Click','My Div');
});