Browser tab tracking10 May 2015
Recently I was trying to solve a problem where it would have been quite handy to show if users were actively accessing the site from multiple browser tabs at the same time. So after a bit of thinking and hacking I came up with the following solution.
That’s all pretty straight forward, obviously the tricky part is identifying the browser tab. I’m doing this by using the sessionStorage API where
“Opening a page in a new tab or window will cause a new session to be initiated”, or in fact simply changing domains in a tab appears to reset the session too.
btsg stands for Browser Tab Session GUID.
As mentioned above, in a Rails layout I have this for if a new ID is needed:
Rails tagged logging can easily be used to get it appearing in the logs, just stick the following in