Posts

Showing posts with the label google-analytics

How can I get time on page in google analytics only when a specific event is triggered?

How can I get time on page in google analytics only when a specific event is triggered? 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? 1 Answer 1 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)) By clicking "Post Your Answer", you acknowledge that you have read our upda...