Redirecting all external links to an affiliate link

by roady
2 replies
Hey guys,

I'm looking for a script which can add a certain piece of code in the URL when a user clicks an external link from a website.

Suppose on a webpage of warriorforum, I put an external link to Example Domain - I want that when the user clicks on the link, it should turn out to be -

1) prefix the landing page with tracking.affiliate.com/?parameters=1234&redirect=www.example.com/1.html
2)suffix the link with ?UTM_Source=example.com&UTM_Campaign=xyz

so basically, when the user clicks on the URL, the entire URL should become


tracking.affiliate.com/?parameters=1234&redirect=www.example.com/1.html?UTM_Source=example.com&UTM_Campaign=xyz

While I know that 2 question marks can't appear in the URL, so I will be shortening the URL to

tracking.affiliate.com/?parameters=1234&redirect=tinyurl.com/abc

Can someone help me out with this script?

Also,

There are many different parameters which I want to suffix, but with respect to the external link's domain name.

for example

clicking on warriorforum's link of Example Domain should pick up the suffix of UTM_Source=example.com&UTM_campaign=xyz

however, when an external link is pointing to another domain, say abc.com/1.html, I want the script to suffix a different UTM parameter. Can this be done?
#affiliate #external #link #links #redirecting

Trending Topics