If you are a Google Analytics user (if you’re reading this, odds are that you are) then you probably spend at least a little time each week looking at your stats in Google Analytics.

The Google Analytics main dashboard really highlights just a handful of stats. These include:

  • Sessions
  • Users
  • Pageviews
  • Pages / session
  • Average session duration
  • Bounce rate
  • % of new sessions

Google Analytics has some very inaccurate stats for your site

So there are seven main stats that Google Analytics is presenting to us as being important. Did you know that at least two of these statistics are likely to be extremely incorrect?

Those two stats that are wrong are pages / session and average session duration, as well as all the deeper stats concerning these two stat categories. Bounce rate, while technically accurate, also could be viewed as not being that useful, as it counts all users that don’t go to another page as being bounces, even if that user spends 30 minutes reading a page on your site.

These are kind of important stats to have them be incorrect or inaccurate, but there is a way to alter your analytics to get more accurate tracking of these stats, which is what I am going to show you how to do in this article.

WordPress users, did you ever wonder why there is a big difference between Google Analytics and Jetpack Stats? Then you’ll want to read through this article.

Why Google Analytics isn’t accurate for time on page and bounce rate

Before I show you how to fix your tracking for your site so that your analytics can be more accurate, we should look at why the Google Analytics stats are inaccurate in the first place.

Google Analytics tracks website visitors only when an interactive element “fires” the tracking snippet. The most common interactive element that triggers tracking is the loading of a page.

The major issue with this is that the tracking doesn’t fire for people that just stay on one page and then leave your site. So say a visitor lands on one of your pages. A tracking snippet fires counting their page view, where they came from, and the page they visited. If that person then leaves your site, the time on page will be counted as 0:00 and the bounce rate will be 100%.

Technically, they did bounce. However, what if I told you that same person spent an hour reading the page on your site? Should they really be counted as having spent 0:00 time on page and as a bounce?

Some other examples of how Google Analytics tracks users

Let’s run through a few other examples of how Google Analytics tracking is inaccurate.

  1. User A visits your website and spends 20 minutes reading a post. They then exit your site. Google Analytics counts their visit as 0:00 and counts the visit as 1 pageview and as a 100% bounce rate. It should really be a 20 minute visit, 1 pageview, and 0% bounce rate.
  2. User B visits your website and spends 20 minutes reading a post. They then click to another post and spend 20 minutes there before exiting your site. Google Analytics counts their visit as being 20:00 (20 minutes). However, it really should be a 40:00 visit. The user did not bounce, so the bounce rate for that session is 0% and the number of pageviews is 2.
  3. User C visits your website and spends 10 seconds reading a post. They then click to another post and spend 20 minutes reading it before exiting your website.  Google Analytics counts this visit as being 0:10 (10 seconds). The user did not bounce, so the bounce rate for that session is 0% and the number of pageviews is 2.

You can see from these examples that the issue with Google Analytics is that the last pageview before the user leaves your site isn’t counted. This is because the user doesn’t do anything to get the tracking snippet to fire, such as clicking to a new page.

Now, you can fix your site to get the tracking snippet to fire after a set time, which will give you much more accurate statistics.

Adding code to your site to fire the tracking snippet after a set time for improved google analytics stats

To get more accurate statistics, we are going to add a snippet of code to the body of your website. This can go anywhere underneath the main Google Analytics tracking code.

The code is sometimes referred to as a heartbeat, as it fires after a set time period to notify Google Analytics.

The code you want to add to the body of your site is:


setInterval(function() {

ga(‘send’, ‘event’, ‘HeartBeat’, ’60s’);

}, 30000);


In that code, you can see the ‘60s’ part. That indicates that the heartbeat goes off every 60 seconds, notifying Google Analytics that a user has been on the site for that 60 seconds. You can adjust that time period to be anything you want.

This code is for the Google Universal Analytics only. That is the type of analytics you should be using, and, if you are not, I recommend updating.

If for some reason you want to use classic analytics, the code would instead be:


setInterval(function() {

_trackEvent(‘HeartBeat’, ’30s’, ’30s’, 0, true);

}, 30000);


If you are using Google Tag Manager, there is a way to setup a trigger tag with a time interval. I won’t cover that in depth in this article. If you want to set that up, follow Google’s guide.

Some issues with the heartbeat code

Before you enact this code on your own website, you should be aware that it could or even does mess up some of your other statistics, particular the bounce rate. If you want your bounce rate to be every visitor that doesn’t visit a second page (so visitors who view one page and leave) then you shouldn’t add this code to your site. If you want the bounce rate to be a metric of whether people actually stay and read your content before leaving, then add the snippet to your site.

The lower you set the heartbeat interval, the greater difference you will see in your stats. I would recommend initially setting the interval to being something higher, such as 300s, which is 300 seconds or 5 minutes. This will help you ensure that anyone spending 5 minutes on a page on your site will be counted as a pageview. Doing this alone will raise your average time on page, pageviews, and lower your bounce rate.

After running the heartbeat at a high interval, you may discover that most people are only spending 3 minutes on your pages on average, and you then can adjust the interval to be something like 2 minutes and 45 seconds so that people spending the average time on your site are all counted. This will again raise your average time on page, pageviews, and lower your bounce rate.

You could continue to adjust the heartbeat interval until it is to your liking. You likely want to pick a cutoff for what you consider to be a bounce and not go below that. If a user spends less than 30 seconds on your site before exiting, I really wouldn’t count that as a real visit, so I would keep my heartbeat interval at least above 30 seconds. That user that spends less than 30 seconds on your site just didn’t have time to seriously read your content. I would say that user bounced. Therefore, I am fine with having that visitor counted as just 1 page view of 0 seconds with a 100% bounce rate.


In this post, I showed you how to enact a Google Analytics heartbeat on your website so that your tracking snippet fires at a set interval, giving you more detailed, more accurate Google Analytics stats.

Now go ahead and gives this a try! For those of you that are constantly watching your analytics, it is a lot of fun to all of a sudden see your average time on page and pageviews jump while your bounce rate plummets.

Did you enjoy this post?

Join our mailing list to be notified when we publish more!

Awesome! Thanks for subscribing!