Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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

After visitor lands to my webpage using campaign url:


Is it possible to do a rewrite to http://www.mydomain.com to cleanup the URL in the address bar?

Will it still preserve the campaign data if I do a simple mod_rewrite redirect?

RewriteCond %{QUERY_STRING} utm_source
RewriteRule .* http://www.mydomain.com [R=301,L]

Or how else can I cleanup the URL?

share|improve this question

It's possible by using server side redirection AND by following the instructions on this Google reference page:


Please note that the _setCamp... functions must be called before this code:

share|improve this answer

If you redirect, it will not preserve that information. You could store this information in a cookie before redirecting and then read it from a cookie. I worked with a website that did that for URL canonicalization. It works, but it is a pain to implement and some data gets lost or truncated.

share|improve this answer
OK, so how do I transfer the data from PHP variable (cookie) to Google Analytics Campaigns? – Joudicek Jouda Dec 17 '13 at 21:07
I guess that won't work. I've logged cookies for my own analytics, but never sent them to Google Analytics. – Stephen Ostermiller Dec 17 '13 at 21:12

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.