I run a standard google analytics tracking code (ga.js asynch version) on a website.
I am wondering if there is a line of js I can add to the tracking code so that I can segregate dev/prod data? e.g. when I pull in the codebase to do dev work, I can set the tag to DEV. When releasing back to production, DEV tag gets replaced with PROD tag.
Is this even possible and if so, how do i implement it?
One method I thought of is just to create a new “property” (which would generate a new ua number, which I could add during dev. that would allow me to track it all separately.)
Wondering if there are any other methods I should consider.
I’m not worried about collecting data from my development server, but I do want to make sure I’m not polluting my production data — I’ve been using some variation of the following:
On the devserver domain (or on localhost),
_setAccountdoesn’t get executed, so the tracker defaults to the default tracker,UA-99999999-1. This allows you to still see tracking data being sent to the analytics servers (via ga_debug.js, chrome dev tools, firebug, fiddler, etc), but doesn’t register against your production profiles.Downsides — it is an extra bit of code that get’s run on the client.
If you do want analytics from your development servers, you could try something like: