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

After visitor lands to my webpage using campaign url:

http://www.mydomain.com?utm_source=signature&utm_medium=email&utm_campaign=myname

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
add comment

2 Answers 2

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
add comment

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

https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiCampaignTracking

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

_gaq.push(['_trackPageview']);
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.