Advanced Techniques in Google Analytics to enhance SEO Reporting: Part 2
Stop Google resetting after 30Min’s resulting in duplicate visits
In part 1 I explained how I how to edit the Google Analytics code to add a second tracking code to websites with multiple domains to enable an additional “roll up report” to be added where a client can get data from all their websites into one simple report.
In part 2 I am going to look at another aspect that can cause issues for your SEO reporting and how to fix this with different edits to the GA code you install on your site. If you are reporting to clients you need to ensure that the results are accurate as misleading data can lead to making incorrect judgements about the performance of a website
By default Google Analytics will automatically reset itself after 30Min’s of inactivity. So if a user is on the site for more than 30Min’s, doesn’t leave your page but returns later than 30mins then they will then be classed as a second visitor. This will make the number of visits your site has received inaccurate and may give you exaggerated data.
By calling “setSessionCookieTimeout” you can change this default and make the timeout as 1hour or more as to your preference as shown in the example below:
<script type=”text/javascript”>// <![CDATA[
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-1']);
_gaq.push(['_setSessionCookieTimeout', 3600000]);//change session to 1 hour
_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);
})();
// ]]></script>
This edit can be set at what ever value you wish but it must be set in milliseconds as shown in the example.
This will ensure that particularly if you have a site where the average time on site is quite high. In this case you may wish to consider this option of editing the Google Analytics Code to ensure that you data is accurate and you don’t have more visits listing on your results than what is true.
