Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I have a website with two versions, one for production and one for development (testing new features). All of the code is under version control and the websites are on separate servers.

Currently, I have the same Google Analytics Tracking code used on both sites. Since the code is under version control, it would be ideal to either have an if I am on production, use this code; else if on development server use that code clause. But I suspect that Google makes it easier to do something like this.

I see that there are many ways to configure a GA tracking code, e.g. "a single domain" vs. "multiple top level domains". But it is not clear to me how to set this up.

Also, if tracking code configured for a single domain has been on the development server, have I been picking up traffic to both sites, or does GA just ignore the second domain that I haven't registered?

share|improve this question
1  
you, most probably, have been picking traffic from both. –  PatomaS Oct 19 '12 at 1:09
2  
Hi have a look at this answer stackoverflow.com/questions/11110660/… Hope this helps –  Renzo Jan 4 '13 at 10:29
add comment

2 Answers 2

I see that there are many ways to configure a GA tracking code, e.g. "a single domain" vs. "multiple top level domains". But it is not clear to me how to set this up.

The single/multiple domain setup has nothing to do with your test environment. It's supposed to be used when in production you have one or multiple domains accordingly.

To remove development and testing data from Google Analytics I recommend using a filter if you have a static IP address or if you don't just create a filter that executes the Google Analytics or not based on a check if the current environment is production or not.

Also, if tracking code configured for a single domain has been on the development server, have I been picking up traffic to both sites, or does GA just ignore the second domain that I haven't registered?

You've been picking traffic from both.

share|improve this answer
add comment

I have been working on something similar and the solution I came up with was to include my analytics snippets via PHP (rather than pasting the snippet itself into the pages/templates). On the development server I have the snippet itself commented out and I have the file(s) which contain the snippet listed in my .gitignore file.

Another simple way to do this would be via a tag manager.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.