Testing Google Analytics code in Dev environment before Live

By sumedhinamdar

Here is a typical scenario…

Every site will have a Dev and Stage environment to test the code before taking the build live.

These environments would typically not be accessible from outside world…

How can we test google analytics code in such a case? Any pointers?

I know I am supposed to put answers here, not questions… :)

May be I’ll post a follow-up to this question…once I get something…

I tried to Google this, but so far haven’t found anything significant exceptthis, and even that doesn’t have exactly what I am talking about…

Ideally, I would want to track the Dev environment in a totally separated section…Would I need to create  2 accounts?  Even if  I do create  2 accounts, How do I make my Dev server accessible to Google Analytics?

Tags: , ,

5 Responses to “Testing Google Analytics code in Dev environment before Live”

  1. Michael Says:

    I am aslo interested about having goggle analytics on my blog. The dev server that you are trying to setup is it behind a firewall or is within an intranet. I am asking the following questions because you need to have your server available to the public in order to activate the goggle analytics script installed on your server.

  2. Sumedh Says:

    An update…

    I set it up for my dev server that is not exposed to external world…

    And Google Analytics is correctly receiving data… :)

    So no special configuration is necessary!

  3. Nigel Fernandes Says:

    Hi Sumedh.n

    Nice of you to stop by my blog. I used to work for BookEazy, and was one of their first employees. Since March this year however I have been working with ThoughtWorks

    I was trying to make to Delhi for BarCamp. But that did not happen. I live and work in Pune.

    Sorry for spamming your blog post but I did not know how else to contact you.

    Regarding this post here (just so this is not pure comment spam ;-) ), I kn ow its a little be dated but here are my thoughts

    a) Why do you want your track your Dev environment pings to Google, or to actually run the Google Analytics code ? That will just slow your development down since the pages times will take longer. (Have to connect to the google servers …)

    b) Google Analytics runs as Javascript within the page. You do not need to make your server accessible to google. You just need to have your client accessing your server page (i.e. your browser able to connect to Google)

    c) You can set Google Analyitcs to ignore all hits from fixed IPs. If you are on a fixed IP address, the hits from the dev machines will not mess with your live data.

    d) If you want to test functionality related to the Google Analytics code ina page, (lets say for example you are usign a server side script to dynamically generate a Google analytics segment setting snippet of Jav)

  4. Nigel Fernandes Says:

    Oooops… hit enter to0 early.. as I was saying:

    …script to dynamically generate a Google analytics segment setting snippet of Javacript), well then you could write a test that checks for the presence of the code snippet in the page
    I suggest using Selenium for something like this.

    e) ping me back if you’d like to discuss this a little bit more.

    BTW if you’d like to get in touch with the folks at BookEazy let me know. The founders also write a blog at http://www.sukshma.net and you can use that to get in touch with them.

  5. sumedhinamdar Says:

    Hi Nigel…

    Sorry that I didn’t reply earlier…

    a. Want to put it on Dev to test it of course Yaar… :)

    b. Well, When you set it up, Google tries to verify the analytics profile code…that made me think it needs to be accessible…but yeah, it’s not necessary…once Google gets the data…it starts to store it…

    c. Yes…we use that, to filter our internal traffic to live site…

    d. I dunno selenium, but nothing can replace actual testing right? Simple URL’s are tracked correctly, but other stuff gets complicated…

    Yeah, I know Santosh very well…we have met a few times…in Mocha… :)

Leave a Reply