Tapestry Training -- From The Source

Let me help you get your team up to speed in Tapestry ... fast. Visit howardlewisship.com for details on training, mentoring and support!

Thursday, October 28, 2010

Google Analytics vs. localhost

Are you using Google Analytics and trying to test it on your pages? Does it appear to do absolutely nothing?

After a lot of playing around, we discovered that Google Analytics appears to check if the URL is for "http://localhost" (any port) and disables itself. No warning, even if you are using the new debug version of the Google Analytics script (which is still minimized and obfusicated, which kind of flies in the face of debugging). The GA script just does nothing.

Re-open your page using "http://127.0.0.1:8080/" and it works like a charm.

There is the briefest of mentions in a comment in their forums that kind of indicates this is how it is supposed to work. Ugh. It should be in bold font: This script disables itself when the accessed page is on localhost.

It does make sense that you don't want to flood GA with spurious page hits while you are developing and testing your application ... but would it kill them to send a warning to the FireBug console?

Update: using the asynchronous API along with the debug version (.../u/ga_debug.js) does appear to work, even on localhost. When I first looked at this a couple of months ago, the debug script was not available.

2 comments:

MastermindCriss said...

Thanks man, You saved lot or our time (But actually we already wasted it before coming here. ).

You rock.

Howard said...

I can tell you that I felt like an idiot ... you know, I can write Tapestry but I can't get GA working, which any 'effn coding drone can do in their sleep.