Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Average Visit Duration spikes at midnight

Last thursday I implemented a change to our GA script - I added the Enhanced Link Attribution and added the setDomainName attribute. Since then, most of our stats are fine, but the Average Visit Duration has gone completely insane.

We went from averaging around 4mins/visit to massive spikes every morning after midnight of visit times exceeding two hours. I figure it must be something I did wrong, as it started going out of control about the same hour that I deployed the change.

I don't want to flail about making changes on production until I can figure out the cause - any help or suggestions would be greatly appreciated.

Hourly analytics for Average Visit Duration:

Visit duration starts as averaging 3min, after Thursday it starts spiking each morning just after midnight around 2 and a half hours/visit, and dropping down to about 4min/visit by the end of the day.

The current GA script

var _gaq = _gaq || [];
var pluginUrl = '//www.google-analytics.com/plugins/ga/inpage_linkid.js';

_gaq.push(['_require', 'inpage_linkid', pluginUrl]);
_gaq.push(['_setCustomVar', 1, 'Locale', 'en_CA', 2]);
_gaq.push(['_setAccount', 'REDACTED']);
_gaq.push(['_setSiteSpeedSampleRate', 10 ]);
_gaq.push(['_setDomainName', 'REDACTED']);
_gaq.push(['_trackPageview']);

(function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
like image 335
Jay Avatar asked Apr 05 '13 18:04

Jay


1 Answers

EDIT I solved it. See details below - but summary is that its a symptom of auto-refresh javascript causing sessions that span multiple days. GA resets all session at midnight so it appears as if many long session start at midnight, but they don't, they may start at any hour of the day.


Did you ever figure out what the cause was? We are seeing the same thing, huge spikes in average session length - just started recently. Also at midnight.

We tried what @newUserNameHere suggested - we created an advanced segment for these long sessions (sometimes spanning up to 10 hours, but averaging 1.5 hours) - and we saw that it is made up of about 700 unique users - spanning all browser versions, including multiple dot patch versions of chrome, and spanning the entire world and the entire US. So it doesn't seem like its a single bot...or at least if it is - it is a very distributed and varied bot(s)? Chart1chart2

Edit

I solved it!

I turned out the developers have implemented an "automatic" refresh on our site, every 15 minutes. This essentially caused Google Analytics to see any user who kept their browser open as an endlessly long session (as long you hit the site within 30 minutes, it extends the session). Since Google Analytics resets all sessions at midnight, and since the graph above displays sessions based on when they STARTED - we are seeing many many very long sessions starting at midnight. Where in reality, the long sessions just continue all day long, and can start whenever.

This was actually requested by our Product team, but I had no idea.

After drilling down into the data in Google Analytics, I just theorized that something like that must be going on, contiously pinging the site (or at least Google Analytics) to keep the sessions live before 30 minutes are up.

I left a browser open with Charles HTTP Debugger open as well, for a few hours to see what was going on, and I discovered this behavior.

When I brought this back to the developers and to the Product team, they said "of course, we just asked for and implemented this behavior 2 weeks ago."

(Actually seems strangely, gratifyingly scientific. I saw some wierd symptoms. I had a theory as to what could cause it. I set up an experiment to test it (Browser+Charles open), and the experiment proved my theory.)

If you are still seeing this problem, I would suggest trying the above method (leave a browser open for a few hours, along with Charles HTTP debugger). If you don't see the page being refreshed regularly, perhaps its not the homepage - you should use an advanced segment to determine which page this is happening on, and try this on that page.

like image 157
Gal Avatar answered Oct 02 '22 10:10

Gal