Suppose I have the website www.example.com and www.example2.com. I redirect all page requests from www.example2.com to their corresponding pages at www.example.com. Is there a way for Google Analytics to track visits at www.example2.com?

This question came from our site for professional and enthusiast programmers.

If they are never on example2.com because of the redirect, how can you track them if they can ever use the example2.com website at all since it really doesn't exist?
–
John Conde♦May 2 '11 at 3:21

Precisely. Thinking of putting GA code in one page then do redirects using javascript. What could be the negative implications?
–
DaveMay 2 '11 at 3:39

Doing redirects with JavaSCript is a bad idea. If someone doesn't use JavaScript, like search engines, they don't get the redirect. Then you have duplicate content issues and can confuse your users. Use a server side 301 redirect. That's the infallible way for this to be done.
–
John Conde♦May 2 '11 at 11:40

(i.e. your redirect would always append the ?utm_source=example2.com&utm_medium=Redirect&utm_campaign=Redirects query to instruct Google Analytics to track the hit as a campaign link; the downside to this method is that, should the visitor share the link with the appended query string, other hits which are not necessarily redirects would appear under the Redirects campaign)