How to record every moment in google analytics?

与世无争的帅哥 提交于 2019-12-08 07:50:56

问题


i have implemented simple Google Analytic so for in my technical carrier, i.e. pages viewed by audience are recorded in Google Analytic. now one of my client is asking to record everything happens on the page, like click on specify buttons and video play, stop, time duration of video user watched. I have did some R&D on this and found Event Tracking - Web Tracking (ga.js) from google.. but i am not sure how to use this. and I also want to know, is this feature is only for paid users? or free users can also use this option. Please help me.


回答1:


Event tracking in GA is awesome and totally free. You can track anything with it like buttons, clicks, youtube videos, pdf downloads, js form submissions ect ect.

Here is the basic layout for ga.js (the older version of GA): _gaq.push(['_trackEvent', 'Category', 'Action', 'Opt Label', Opt Value, 'Opt non-interaction'])

Here is the breakdown and what each part means.

'_trackEvent' – This is a JavaScript method that starts out the array.

'Category' – the category that you want to show up, use something broad like external links, social links, images, videos, or form.

'Action' – This is the action that occurred; something the user did that you are tracking. For the ‘Action’ property use clicked, submissions, copy or whatever you are tracking from the user.

'Optional Label' – This is an optional field you don’t need anything, but when you start tracking a lot of stuff you want to be able to segment it out. For this property think of it like a specific category for example, facebook, box 2, or headline picture.

Optional Value – This is a number value for the thing you are tracking. There is no need to put quotes around the numerical value because its a number.

'Optional Interaction' – This one is a little tricky, it’s a Boolean value and it’s default is false, so if you don’t put anything it will be false. False means it won’t touch your bounce rate, but true means that it won’t count that visit as a bounce.

If you wanted to track clicks on a button you can do it in a couple ways. The easy way is to just add the javascript to the onclick= attribute in html.

<button id='button1' onclick=_gaq.push(['_trackEvent', 'Category', 'Action', 'Opt Label', Opt Value, 'Opt non-interaction'])> Button Text </button>

However, technically you don't want JS mixed in with HTML. It's fine for small stuff but it's better if you create event listeners.

You can do this really easily with jquery. Here is basic click tracking on the HTML button mentioned above.

$('#button1').click(function(){
 //fires the event tracking method when button is clicked.    
 _gaq.push(['_trackEvent', 'Category', 'Action', 'Opt Label', Opt Value, 'Opt non-interaction'])
})

What in particular are you looking to track?

Note: the layout changed in analytics.js (Universal Analytics) you can read about that here.



来源:https://stackoverflow.com/questions/21520268/how-to-record-every-moment-in-google-analytics

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!