1

I have a link to a site i manage on a 3rd party domain.

The link is actually to an old site which i then 301 to the current site.

All the sites are http, but somewhere along the way the HTTP refer tag gets dropped so i cant see the referring site in google analytics.

If i used a UTM link tracking URL as the URL for the 301 re-direct would that work to allow me to see where the visit came from in google analytics ?

1 Answer 1

1

Google Analytics is JavaScript code that runs in your page. To track UTM parameters, the JavaScript looks at the page URL, sees if there are parameters in it, and sends them to to be tracked.

Putting the tracking parameters on a 301 redirect URL won't get them tracked by Google Analytics unless they are passed on to the final URL.

  • Tracked: http://example.com/page?utm_campaign=... -> https://example.com/page?utm_campaign=...
  • NOT tracked: http://example.com/page?utm_campaign=... -> https://example.com/page

By default most redirects strip the query string from the redirect URL. mod_alias under Apache does so. mod_rewrite also does unless you use the QSA flag for "query string append". If you implement your redirect with mod_rewrite and want to preserve the query string using the flags [R=301,QSA,L] as in:

RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://example.com/$1 [R=301,QSA,L]
1
  • Thanks Stephen, im using the following (which ive added the QSA flag to). Would this work ? RewriteEngine on RewriteRule ^ https://example.co.uk/?utm_source=tg? [R=301,L,QSA,NE]
    – sam
    Commented Mar 31, 2019 at 12:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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