+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Google Analytics and non-production environments

Google Analytics and non-production environments

5 posts, 0 answered
  1. Marko
    Marko avatar
    148 posts
    Registered:
    30 Jul 2008
    21 Feb 2013
    Link to this post

    I'm wondering what do people do regarding preventing Google Analytics from reporting usage statistics from a development/staging site.  For example, in my case, I have Google Analytics widget dropped on several page templates.  I periodically copy the whole production site down to my development machine, so that I can ensure to be working with most current data.  If I'm not mistaken, even though my production site and domain might be www.mysite.com (which has been registered and verified with GA), and my development site might be http://localhost:xxxx or something like that, I believe that GA still receives usage statistics when I open the pages on localhost to test them, correct?

    I know I can set up filters in GA (e.g. IP numbers, etc.), but I thought it'd be great to have some sort of a "switch" in sitefinity, a global setting of some sort, that can enable/disable GA throughout the site as needed.  There isn't anything like that already built-in, is there?

     What do others do regarding GA and non-production sites?  Is it a concern at all?  I'd love to hear some best practices on this.

  2. Arno
    Arno avatar
    249 posts
    Registered:
    08 Sep 2010
    21 Feb 2013
    Link to this post

    Hi Marko,

    GA will just see if it can match the profile ID (UA-xxxxx) in the request with one of its accounts, regardless from which domain (or localhost) it originates. So this will pollute the tracking data if you don't have further filters. I prefer to configure a separate web property in GA, for test/staging, which will have its own profile ID. Then in .NET I will use one ID or the other, depending on where the site is currently running. One advantage is that you can test GA functionality very well.

    I don't know if Sitefinity can help with this. I have the preferred domain as a setting in web.config and a function to check whether the site is currently running locally or not (i.e. does the domain contain "localhost" or not).

  3. Marko
    Marko avatar
    148 posts
    Registered:
    30 Jul 2008
    21 Feb 2013
    Link to this post

    Thanks for your input, Arno.

    I suppose I could set up a different GA profile with its own ID number.  But that would require me to  open each of those Page Templates and edit each instance of GA Widget in order to change the ID number, correct?  It might be better if GA configuration was somehow centrally managed, but with ability to place the GA widget only on pages/templates which are needed to be reported.

  4. Arno
    Arno avatar
    249 posts
    Registered:
    08 Sep 2010
    21 Feb 2013 in reply to Marko
    Link to this post

    I haven't been using the build in GA functionality of Sitefinity yet. My approach is what I use in the site I'm currently converting to Sitefinity. I plan to stick to that approach and just create one custom function that outputs the GA script with the correct ID, depending on the hostname. Then it's just a matter of calling that function from the base template (either in a widget or not) and it will always use the correct ID.

  5. Marko
    Marko avatar
    148 posts
    Registered:
    30 Jul 2008
    21 Feb 2013
    Link to this post

    I see.  I had a custom approach in our previous Sitefinity site (3.7) as GA functionality wasn't built in.  I had a application variable in web.config called "EnableGoogleAnalytics='true/false'" and some custom code in the root master page.  The code depended on EnableGoogleAnalytics value in order to determine whether to insert GA code or not.  Naturally, on production site, the app variable was set to true while in dev/stage it was false.  It was simple, easy, and worked like a charm.  :-)

    With our recent migration to 5.3, I started removing some past customizations and replacing them with built-in functionality (if there exists any for the desired effect), in a goal of having a cleaner and more "compliant" environment.  I hoped that this would be one of those settings. 

    But perhaps it's not mature enough, yet.  :-(

5 posts, 0 answered