I'm using some kind of a server setup that uses Node.js/Express to build a web-application (a collaborative whiteboard).

The way I have things setup on my server is this.

My user visits this URL:


The roomName part is not really a subpage. I redirect to page www.sitename.io/go/ via my server-setup(Express Routes) and I use the last part of my URL as a parameter of some sort to create some WebSocket connections.

So for example all these addresses will land the user to the same page (which is www.example.com/go).


Long story short:

The last part of the URL is not an actual "page". It's simply used as somekind of a parameter.

The problem.

The issue I'm seeing is erroneous/unreliable Google Analytics tracking data.

There are certain cases where I should be getting in Google Analytics a certain 2:00 hours Avg. Time on Page but instead it records it as 0:00. In general I seem to be getting unreliable/erroneous tracking.

What I think is the issue.

I'm thinking that the whole setup where my URL does not redirect to the last part of the URL(it's not an actual page but is simply there to be used as a parameter), is what's confusing/causing incompatibility issues with Google Analytics.

Here's the Google Analytics data (I'm getting 0:00 time in places where I should be getting at least 2hours +).

Google Analytics data screenshot

1 Answer 1


By default Google Analytics doesn't know when a user leaves the page unless they go to another page. If your visitors view only a single page they get 0:00 as their time on site (and average time per page.) It sounds like you have implemented a single page application, so this is going to be an issue for you.

You can fix this by implementing events. As the user interacts with your page you can ping Google Analytics through JavaScript to send it tracked events. The time on site will then include any time until the user's last event.

  • Thanks - I understand that I can send an G.A event on beforeunload event - I am somehow confused as to which event I need to send though. ga('send', 'event', '???'); - Which event fits the bill here? Jan 13, 2016 at 12:11
  • Before unload events are unreliable. Analytics calls are asynchronous and the page often get alerted before the event is fired. instead you should fire events or actions your users take proactively. Jan 13, 2016 at 12:52
  • Makes sense - However the question I'm having now is a bit different. Which event should I send in order to "end" the tracking. As I understand it G.A doesn't have an "end" timestamp to compare with the "start". Which event from the G.A methods instructs google to end the time-trackiing - In other words which event should I send? Jan 13, 2016 at 13:08
  • There should be no "end" event. Rather events should be "User did X", "User did Y" Then hopefully one of those events will be close to the end. Jan 13, 2016 at 13:09
  • I think I get it now. And all these events will contribute to the "Avg. Time on Page" right? Jan 13, 2016 at 13:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.