Display different Website Content based upon Site Referrer / Affiliate Link - for cloaking

therabbitking

Newbie
Joined
Jul 24, 2020
Messages
30
Reaction score
5
Hello, I was wondering if anyone here knows a way to display different website content based upon site referrer / affiliate link.

I want to setup something on my website...

So let's say 1 visitor just goes to a webpage directly and another visits via an affiliate link such as examplesite.com/?rel=1 , I would like to setup something so that the user who visits the webpage via the affiliate link will see different content than someone who visits the webpage from another source.

Does anyone have advice or a solution for this?

2. Would it be possible to setup something so anyone who visits examplesite.com without an affiliate link gets redirected to another url, while anyone who visits via an affiliate link such as examplesite.com/?rel=1 - doesn't get redirected.

Thanks
 
You can do this in Javascript, I think this is what I did when I finished a similar thing recently;

JavaScript:
if(window.location.hash) == "#xxx" {
    #something to run
} elif(window.location.hash) == "#yyy" {
    #something else to do
} else {
    #something else to do
}
 
const isAffLink = window.location.href.includes('?rel=');

isAffLink will be true if '?rel=' is in the url.

That would be one way to do it.
 
Back
Top