Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Currently, I use Google Analytics for www.example.com. example.com is also added to GA and shows "Tracking not installed".

Recently I added rewrite rule (301 redirect) to redirect all requests from www.example.com to example.com.

How should I move/update GA code to properly track visits to example.com?

share|improve this question
up vote 3 down vote accepted

If I understood this correctly, you want to have all visits to the site redirected to the domain (not the www subdomain), but you have the GA code set up to track the www subdomain. I think the best way to do it is edit the settings in GA to point to example.com. When you go to GA, you should have two links in the right of the account name, edit and delete. Clicking edit will allow you to change the website URL so you're good to go and still get to keep the old data in as well.

share|improve this answer

Check out the Google Articles on how to do it.

One thing Google doesn't mention for Asynchronous tracking. If you have DomainNames set within your GA account you will need to have the middle line from below

var _gaq = _gaq || [];
           _gaq.push(['_setAccount', 'UA-XXXXXXX-1']);
           _gaq.push(['_setDomainName', 'www.example.com']);

Adding that line will make sure you are tracking against the correct domain.

share|improve this answer

If the code is included in the pages it's already working. You're able to break out reporting in Analytics to give you different reports based on the sub-domain the code is sitting on. If you want to create different accounts for each you can, which requires a different UA ID to be specified in the code. However if you're fine with doing it on the reporting side you're already done.

share|improve this answer

Your Answer


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.