I'm making a web application that's focused around watching embedded content. I would like the application client to send a "heartbeat" type of signal to GA (Google Analytics) to keep the session going. It seems now that if the visitor watches a video for 5-10 minutes GA assumes that he has left the page and registers an action from the user as a new session.
I'm making this assumption after I got a few hundred people to test the application and the GA Real-time beta registered ~100 people on the page. After a few minutes the numbers started to drop drastically, even though almost all the visitors were still using the application to watch live streams.
Thanks
I would fire an event every 10 minutes with opt_noninteraction set as true.
function ga_heartbeat(){
_gaq.push(['_trackEvent', 'Heartbeat', 'Heartbeat', '', 0, true]);
setTimeout(ga_heartbeat, 10*60*1000);
}
ga_heartbeat();
You could even set the timeout to be longer. Maybe 25 minutes. It just needs to be shorter than 30min and longer than 10 seconds, otherwise it would be impacted by hit throttling.
Note that GA also has a restriction of 500 hits you can send per session/visit. Using something like this can lead you to reaching this limitation more often. After the 500 hits/session limit is reached any extra info sent by the user is just ignored by Google Analytics for that specific session.
Google gives you control over the session timeout. See here and here for more info where it says that the default time is 30 mins of no activity on the site triggers a new session upon the next activity.
You can also set the session timeout time yourself with: _setSessionCookieTimeout(cookieTimeoutMillis)
as documented here.
I do not see any evidence of any specific support for a heartbeat to prolong a session on a given page. You could set your own timer and register a new pageview every N minutes whenever content is being watched as that should serve the same purpose.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With