Reputation: 4862
I have a page where the user can either click save or send. I would like to know the average time on the page only when the user clicks send. Is there a way to do this in google analytics?
Upvotes: 1
Views: 143
Reputation: 4862
I did this by triggering an event on send and adding the time on page as the value of the event. Then in the google dashboard you can see the average value of the event, which is the average time on page.
//start counting for google analytics on page load
sessionStorage.referral_start_time = Date.now()
//send event
ga('send', 'event', 'event category', 'event action', 'event name', Math.round((Date.now() - sessionStorage.referral_start_time) / 1000))
Upvotes: 1