0

I have website domain1.com and domain2.com. Suppose a user gets to domain1.com from theoriginalreferrer.com then clicks on a link to domain2.com.

In this scenario, I'd like to pass on the referrer of domain1.com to domain2.com - ie I would like the document.referrer of domain2.com to show theoriginalreferrer.com instead of domain1.com. Is this possible?

I realize one option is to simply add a query string to the link to domain2 to be domain2.com?referrer=... and inject the existing document.referrer from domain1. This is not ideal for my situation and I'd prefer to be able to somehow directly affect domain2's document.referrer when a link is clicked on domain1.com

wlingke
  • 4,699
  • 4
  • 36
  • 52
  • You could save the referrer and use it in `domain2.com`. Have you tried anything? Your goal seems a bit arbitrary. Why `google.com`? How many levels of referrers should this cover? Can you generalize your requirement a bit? – Sebastian Simon Aug 25 '16 at 17:48
  • @Xufox Happy to clarify but you didn't have to downvote the question... All I am asking is whether its possible to overwrite what the referrer is when a link is clicked on a site. google.com is arbitrary. And sure I could save the referrer on domain1 and pass it as a query param to domain2 but that is not what I was asking... – wlingke Aug 25 '16 at 18:52
  • Yes, I did have to downvote, because no attempt was shown and the queston was unclear. – Sebastian Simon Aug 25 '16 at 18:59
  • @Xufox Hope I have clarified enough now. Would you please remove the downvote? If not please indicate what additional info you think would be necessary. – wlingke Aug 25 '16 at 19:11
  • Yep, it’s fine now. – Sebastian Simon Aug 25 '16 at 20:04
  • 1
    Are you trying to just see the original referrer in document.referrer, or are you trying to alter the Referer HTTP header in the request to the second site? If the latter, I don't think you can alter Referer headers in script, so you would have only 2 options. 1 using querystring, second using jscript to handle all hyperlink clicks and convert them to posts with the referrer as form data. Probably neither is a good option. – Adrien Aug 29 '16 at 03:26
  • @Adrien got it - thanks! – wlingke Aug 29 '16 at 16:08

0 Answers0