I'm monitoring traffic from Google, and if the traffic source is google, I want them redirected to the same URL, but with an appended GET variable, such as http://example.com/article should be redirected to http://example.com/article?source=google

I have hooked in to the hook wp, and added an action to check the referrer. If the referrer is google, it redirects them to the 2nd version of the URL. Unfortunately I'm developing locally and can't really test the referrer properly, so I'm wondering, as far as google analytics, and other tracking services, will the referrer stay as Google with wp_redirect, or will the referrer be changed to my own site?

I am using a 302 redirect.

  • This article shows that it's kept atlantaanalytics.com/practicing-web-analytics/… Any other conflicting issues here with WordPress? – user3657553 Feb 11 '15 at 17:44
  • So, you run WordPress and redirect to same page running again WordPress for the same task and same visit/visitor. I think you should think again about what you want to do and how it should be done. – cybmeta Feb 11 '15 at 17:54
  • That's why I'm here, to get advice from others. Yes, I'm trying to serve two versions of the same page, as a split test. However if google indexes ?version=1 first, then the split test is majorly skewed and version 1 will show as the winner, when in fact, it was just indexed first. I'm trying to prevent this from happening by saying "If the visitor is from google, clear out the version number, and pick a new one. If the one picked is not the one linked to, then redirect them to that version, but track the referrer" – user3657553 Feb 11 '15 at 17:56
  • My advise is to not make a redirect. Just pick up the referrer and use template_include filter to choose a different template if the user comes from Google. You will gain in performance. By the way, if Google notes that you are serving different content for the search engine you will be banned. – cybmeta Feb 11 '15 at 18:15
  • There are two versions of the same article, the only difference is the title, and featured image. I do not need a new template for this, but it might be an option. Version 1 is standard, and will be sent to users and google, version 2 will be randomly sent to users. There will be a 302 redirect from ver 1 to ver 2 for the users, and a canonical tag if we decide to change the URL. The content in the search engine will not be different. Thanks for the suggestion, I'll look into templates for this. – user3657553 Feb 11 '15 at 19:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.