Tracking the Bounce Rate for a Single Page Visit in GA

in Google Analytics

I've been concerned about the high bounce rates received by this site for a long time: Does the high number mean that my articles are irrelevant to user searches, difficult to understand, or just plain boring? While I'm sure that's true to a certain extent, my return visit rate isn't that bad, but even the bounce rate for the returning visitors is still very high?!

Well, hopefully all isn't lost: Maybe I can gain some insights by having a look at exactly how a bounce is defined, analyzing the type of content my site contains, thinking about the reason people might be interested in such content, and doing some testing using Google Analytics event tracking to reduce bounce rates for people who stay on a page for a while. So, let's get started and see if I can boost my ego a little bit here….

What is a “Bounce” in Google Analytics?

Google defines the Bounce rate metric as "the percentage of visitors that see only one page during a visit to your site": meaning that the user either left your site without loading another page (either via a link or refreshing the current page), or didn't load another page before their GA session expired. This is different to what's commonly called a “Short Click”, where a visitor quickly notices that the page they've landed on doesn't have the information they want and promptly moves back to their original location.

This raises the following two questions:

  • Does it matter if people leave my site after only viewing a page?
  • Are people actually reading my content or just leaving my site very shortly after arriving?

The answer to the first question requires some thought about the value of the content on my site, while the second question can be tested using some modified GA tracking code.

Why Might a Visitor Want To Read the Information on My Site?

The relevance of a bounce to the value of the content on a site depends on who's perspective you take:

  • A site owner will normally want the visitor to perform an action on their site that's valuable for them; however, it usually requires more interaction with a site before a visitor is engaged enough to take an action that has real value.
  • However, a visitor could well see a bounce as a positive outcome: When you're browsing Google for a quick answer to a question, then finding it on the first page of a site is ideal; the visitor will often leave satisfied with their visit, and may even come back again.

While this is a very narrow analysis of the topic, it's enough for me to form a basic hypothesis about my bounce rate: Given that most of the articles on my site relate to programming topics that developers usually want to find a quick answer to, I believe that my bounce rate could be caused by visitor satisfaction, instead of visitor discontent. A small number of visitors want to find out about me and my products, so will browse further into the site and contact me, which is where my value comes into play; however, most people will find an article on a programming topic, scan through it, copy some code snippets into their IDE, then leave—possibly coming back in the future for more information.

So that's the hypothesis, but I now need to put an experiment together to see if it improves my understanding of the situation.

Is My Site Receiving Too Many Short Clicks?

Ideally, I'd be able to actually survey each visitor to find out if they found my content useful or just meaningless dribble, but in reality most people don't answer surveys unless they're really happy, aggravated, or just plain bored. This means I'm going to have to use the usual method of analyzing click streams with Google Analytics.

I think that a reasonable indicator suggestive of a user actually finding my articles useful would be based on the time they spent viewing them. While my visitors could be just staring blankly at my site, I think that if they spend more than two minutes on a page, then they could well be doing something of value; like reading a tutorial or copying some code. I just need to tell that to Google Analytics.

Changing the Bounce Rate for a Visit Using an Event

The simplest way to stop the bounce rate increasing for a visit is to register a new page view using the __trackPageview() function; however, this approach isn't desirable as it will impact all your other metrics that relate to page views. A better solution is to use Event Tracking because, by default, sending an event to GA will cancel out the bounce. So, just add code similar to the following onto a page, and your bounce rate should go down to zero:

pageTracker._trackEvent('Category', 'Action', 'Label', 'value', false);
Cancelling a Bounce by Sending an Event to Google Analytics

You just need to make sure that the last value is omitted or set to false because it's the opt_noninteraction parameter that stops the event counting towards the bounce rate when it's set to true.

Informing Google Analytics that a Visitor hasn't Bounced

This can now be combined with the window.setTimeout() function to wait for a specified period of time, then send an event to GA to ignore the current visit in its bounce rate calculations. Here's a function, called 'bounceTimeoutFunc()', which does just that:

var bounceTimeoutFunc = function() {
   var pageTracker = _gat._getTrackerByName();
   var minSecondsOnPage = 120;
   var cancelBounceFunc = function() {
      pageTracker._trackEvent('TimeOnPage', 'TimeThresholdReached', document.location.pathname, minSecondsOnPage, false);
   };
   window.setTimeout(cancelBounceFunc, minSecondsOnPage*1000);    
}
A Script to Inform Analytics that a Visitor hasn't Bounced

The first line of the function retrieves a reference to the default GA tracker using the _gat._getTrackerByName() API call; note that this presupposes that the standard tracking code has been installed and run before this function is called.

The next line defines a variable, called minSecondsOnPage that contains the number of seconds you want the script to wait until you consider the visitor to be engaged with your site; I'm trying out two minutes to start with, but you might want to set this to a higher or lower number depending on the type of content you have on your site.

Next we have the definition for a function, called cancelBounceFunc(), that will be called after the specified number of seconds. This function will contain the key line of code that sends a tracking pixel off to GA to register an event:

pageTracker._trackEvent('TimeOnPage', 'TimeThresholdReached', document.location.pathname, minSecondsOnPage, false);
Sending the Event to Google Analytics

I'm giving the event a category of TimeOnPage and an action of TimeThresholdReached; you can use different values if they're more suitable for additional reporting you want to undertake. I've also set the optional label parameter to the name of the current page, the value parameter to the number of seconds I decided to wait, and finally set the noninteraction parameter to false to ensure the event cancels out the bounce.

The final line of code simply registers a timeout event to run cancelBounceFunc() after the number of seconds defined in the minSecondsOnPage variable (the seconds are multiplied by 1000 because the event registration function uses milliseconds, not seconds).

Inserting the Code into your Page

The only thing left to do is place the code onto your page; however, you also need to ensure it plays well with the rest of your GA code, so you need to sequence it correctly using the _gaq: The function assumes that a default tracker is already available so you need to make sure the initial tracking code has been executed before it's run.

This is simple enough to achieve because the function of the _gaq is to queue operations up so they're executed in the correct order; this means that we just need to place our new function onto the queue and ga.js will deal with the rest:

_gaq.push(bounceTimeoutFunc);
Adding the Function to the Tracker Command Queue

Stopping the Event Firing on Subsequent Page Views

You might want to make an additional modification to the code, so it only registers events on the first page of your site; this isn't too important, but reduces network bandwidth a little and will make your event reports clearer should you wish to use them.

A new visit to a site is usually indicated by a HTTP referer header that's not the same as the current domain, so code such as the following should identify it:

var currentDomainName = "ewanheming.com"; 
if(document.referrer.indexOf(currentDomainName) < 0) { 
   _gaq.push(bounceTimeoutFunc); 
}
Restricting the Function to Landing Pages

To get this working you need to enter your domain name into the currentDomainName variable; there's more generic ways of doing this without needing to enter your domain, but this should suffice as an example.

Full Code

For your convenience, here's the code again ready to be placed into a page, so you can see how it all fits together:

/* Standard Asynchronous Google Analytics Snippet */
var _gaq = _gaq || []; 
_gaq.push(['_setAccount', 'UA-XXXXX-X']); 
_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); 
})(); 
 
/* Custom code for stopping visits over a time threshold counting towards bounce rate calculations 
 * To use it you need to enter your own values into the currentDomainName and minSecondsOnPage variables */
var currentDomainName = "ewanheming.com"; 
if(document.referrer.indexOf(currentDomainName) < 0) { 
    var bounceTimeoutFunc = function() { 
        var pageTracker = _gat._getTrackerByName(); 
        var minSecondsOnPage = 120; 
        var cancelBounceFunc = function() { 
            pageTracker._trackEvent('TimeOnPage', 'TimeThresholdReached', document.location.pathname, minSecondsOnPage, false); 
        }; 
        window.setTimeout(cancelBounceFunc, minSecondsOnPage*1000);    
    } 
 
    _gaq.push(bounceTimeoutFunc); 
}
Modified Tracking Code that Cancels Bounces after a Delay

Results After Two Weeks

OK, so after all that, has my bounce rate improved? Well, I guess I wouldn't tell you if the outcome was terrible, but luckily I've seen a positive result! Here's my bounce rate for the past 30 days reported in GA:

The Bounce Rate Report Comparing Two Periods
The Bounce Rate Report Comparing Two Periods

You can see the difference in bounce rate by comparing the last two weeks (in blue) with the previous two weeks (in orange). Apart from the blip on the first of April, the bounce rate metric has seen a significant drop; it's gone from an average of 72% to just 28%:

The Bounce Rate KPI Widget for the Two Periods
The Bounce Rate KPI Widget for the Two Periods

Conclusions

I'm satisfied by my results that people are actually interested in my content: Many people leave my site after only viewing one page, but because of the type of articles I've written, I need to measure how long people spent reading them, instead of how many of them got read during a single visit. However, I should note that this type of tracking will probably work better on an informational site like mine—where success is defined by how useful the information is, not how well it converts into business actions—as sites with a stronger commercial focus need to drive a certain level of engagement, especially if they're paying for traffic.

I think that the most useful outcome of this investigation is that I've cut out some noise, so I can now get a better view of the real bounce rate and time on site metrics, and use them to home in on the content that really is or isn't working.

← No More Email Reports from Facebook Ads Authentication in the AdWords API →

To help me decide what to write about, I'd like to asses the value of my blog posts to see which ones people find most beneficial. If you found the information here useful then could you please +1 it, but if you didn't find what you were looking for then please leave a comment and I'll be happy to help where I can. Thanks!

Comments

I'm keen to get feedback on my posts, so if you have any questions or comments, then please send me a message and I'll be happy to help.

Really a beautifully analytical article. It is like a complete guide on bounce rate. I am completely agree that bounce rate does not matter to sites like yours. As an user comes to your page mainly through search engine. So he gets the idea and leave the site as he requires only that data. So we can't say that the page content is of lower quality.

Reply

cilene

Hi, please I do not understand, "put the ga.js script twice." I put only once. Please, can you explain me better.

And what means " you’re not supposed to do is reverse engineer the ga.js script, or send personally identifiable information about your users to GA–it’s supposed to be an anonymous tracking service"

Reply

Ewan

Hi Cilene,

I think the script is already working: Using live HTTP headers I can see an event request being sent to Analytics; have you noticed a change in your bounce rate yet?

You've probably got two plugins adding the GA code, or maybe it's been added to your theme, but I don't think it will actually cause you any problems if you really can't find out where it comes from.

The bit about reverse engineering and sending personal information to Analytics was just in response to your question about whether Google allows you to modify their tracking code; you don't need to worry about that if you're using this script.

Regards,

Ewan

Reply

If I use this pluign no issues. Could you tell me if this code is accept by Google?

Reply

Ewan

Hi Cilene,

I've checked out your site and it appears to be working now: I can see the event pixel being sent off to Google analytics.

Google doesn't have a problem with you customising their tracking code; they actually have an API for the purpose, and you can read the documentation to find out how it works. The only things you're not supposed to do is reverse engineer the ga.js script, or send personally identifiable information about your users to GA--it's supposed to be an anonymous tracking service.

I also noticed that you included the ga.js script twice; I'm not sure if that will cause any problems, but you should remove it anyway, just in case.

Regards,

Ewan

Reply

yes www.criarblogsite.com I use genesis studiopress template.

Reply

Ewan

I can't see my code on your site? Can you point me to any pages where it's installed? Remember that you're using a caching system, so you might need to clear it before the code takes effect.

Also, it looks like you're using Wordpress; are you using a plugin for Google Analytics? I'm using Google Analyticator and have the custom part of my code pasted into the "Additional tracking code (after tracker initialization):" section.

Reply

no I didnt use plugin. I use genesis admin. And I will send PrintScreen to you so you can see problem.

Reply

do you use all code after tracker initialization or just some part?

Reply

Last question, do you use the all code into the Additional tracking code (after tracker initialization):” section. Or just this part var currentDomainName = ".com"; if(document.referrer.indexOf(currentDomainName) < 0) { var bounceTimeoutFunc = function() { var pageTracker = _gat._getTrackerByName(); var minSecondsOnPage = 60; var cancelBounceFunc = function() { pageTracker._trackEvent('TimeOnPage', 'TimeThresholdReached', document.location.pathname, minSecondsOnPage, false); }; window.setTimeout(cancelBounceFunc, minSecondsOnPage*1000); }

_gaq.push(bounceTimeoutFunc); 

}

Look, I want to say thank you. I have this same problem with my bounce. I've tried everything to resolve, but never found a solution. I hope your system works. accepted Google this method? My Alexa Bounce is great. if your method works, I'll do a post on my blog about your method. Thanks! Please answer all my questions!

Reply

cilene

Look what wrong /* Standard Asynchronous Google Analytics Snippet */ var _gaq = _gaq || []; _gaq.push(['_setAccount', 'ID Google Analytics here']); _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); })();

/* Custom code for stopping visits over a time threshold counting towards bounce rate calculations * To use it you need to enter your own values into the currentDomainName and minSecondsOnPage variables / var currentDomainName = "myurl here.com"; if(document.referrer.indexOf(currentDomainName) < 0) { var bounceTimeoutFunc = function() { var pageTracker = _gat._getTrackerByName(); var minSecondsOnPage = 100; var cancelBounceFunc = function() { pageTracker._trackEvent('TimeOnPage', 'TimeThresholdReached', document.location.pathname, minSecondsOnPage, false); }; window.setTimeout(cancelBounceFunc, minSecondsOnPage1000); }

_gaq.push(bounceTimeoutFunc); 

}

Reply

Ewan

Hi Cilene,

Can you give me the URL of the website you're trying it out on, so I can have a look and see what problem your getting?

Thanks,

Ewan

Reply

cilene

Look /* Standard Asynchronous Google Analytics Snippet */ var _gaq = _gaq || []; _gaq.push(['_setAccount', 'my ID google analyics']); _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); })();

/* Custom code for stopping visits over a time threshold counting towards bounce rate calculations * To use it you need to enter your own values into the currentDomainName and minSecondsOnPage variables / var currentDomainName = "myurl here.com"; if(document.referrer.indexOf(currentDomainName) < 0) { var bounceTimeoutFunc = function() { var pageTracker = _gat._getTrackerByName(); var minSecondsOnPage = 100; var cancelBounceFunc = function() { pageTracker._trackEvent('TimeOnPage', 'TimeThresholdReached', document.location.pathname, minSecondsOnPage, false); }; window.setTimeout(cancelBounceFunc, minSecondsOnPage1000); }

_gaq.push(bounceTimeoutFunc); 

}

what is wrong?

Reply

cilene

Please, I tried to install this system, but the code was appearing in the header. I think I did everything right. I put my domain in place, but did not work. why?

Reply