Web Consulting Washington DC

It’s a dirty job, but somebody’s gotta do it.

Google Analytics: What is this /NaN thing?

May 31st, 2007 by Ernesto Gluecksmann

Recently we started setting up our clients with Google Analytics. After Google’s recent upgrades to a more Ajax styled reporting GUI, we found it to be quiet the upgrade. There’s tremendous improvements in layout and flexibility, along with simplified explanations. Very easy for our customers to get in there and get around.

For one of our clients, we started to see the characters “/NaN” as one fo the pages of significant traffic, located in the Content reports. There’s no page called /NaN, it is actually a JavaScript error that means “Not a Number”.

Well, it turns out that this is usually an indication that there’s some other JavaScript on the web page that interfering with the JavaScript that is download from Google. The way to fix this, is to move Google’s code up into the <head> tag of your web page.

Google Urchin JavaScript Code

We usually add the Google Urchin code at the bottom as indicated by Google, but in this case, the second recommendation it above all other JavaScripts.

Google Urchin JavaScript Code moved

Once we did that, Google Urchin code was run first and that fixed our odd /NaN problem.

7 Responses to “Google Analytics: What is this /NaN thing?”

  1. Kym Says:

    Thanks for posting this.

    We had supposed Google Analystics Experts look at a couple of our client’s site and they never even commented on the funnel showing Nan URLs let alone know the answer!

    You have save us a lot of time!

  2. Ben Says:

    Thanks for this post. I ran into this issue for the first time today and your post is the only answer I could find.

  3. JD Says:

    I tried your solutions and it didn’t work. My google results when flat and the page was not even working. Do you have any other thoughts regarding the NaN problem?

  4. EG Says:

    Hmm, that sounds more like a problem with the page itself. Moving your GA code into different positions, should not affect the page. If you’re saying the page itself is now broken, then you may have overwritten some of page’s important tags. And, GA may skip over broken pages if it can’t tell it’s an HTML document. I’ll email you directly.

  5. Paul Mycroft Says:

    The GA code must be the last thing to load on a page so moving it to the header is not a good idea.

    Trying to troubleshoot the JavaScript error is a better way to go.

  6. Ernesto Gluecksmann Says:

    Hi Paul, you are correct, it is recommended that your GA code be placed at the end of a page. However, it’s not necessarily required. The reason for placing it at or close to the bottom, is if there’s problem with Google itself, it won’t affect the rest of the page from loading. But again, that’s largely mitigated now with modern browsers.

    We deal with a lot of small business clients that don’t really have the budget or expertise to dig through JavaScript warnings to resolve something like this. So… sometimes, good enough.. just is.

  7. Phillip Gross Says:

    I have run into the /NaN issue a few times with clients. It is amazing how overlooked this issue is and and how little support Google offers on it directly.

    Regarding placement of code: Placing the script at the bottom of the page does allows Google to run last and indeed not conflict with other potential elements on the page. This was largely an issue occurring for IE6: Hopefully soon IE6 will be gone and we can all enjoy the web once again. I know every developer out there has lost many hours, days, (or hair) debugging issues with IE6. The new Google Asynchronous tracking code will lighten the load too and actually is place in the element of the page.

Leave a Reply