# Automatically adding referral tags to the end of links



## namenotfound (Apr 30, 2005)

I saw on this one website a few days ago, when someone posted a link to Amazon in their comment section, it automatically received the referral tag of the site owner. How do I do this? How can I put my referral in other people's Amazon links on my website?


----------



## JiminSA (Dec 15, 2011)

You can get your visitor's referrer details from the SERVER using PHP ...

```
[email protected]$HTTP_REFERER;
echo "Referrer of this page  = $ref [/B]";
```
Thereafter, you can display $ref anywhere you choose in your html - e.g.

```
Visited via <?PHP echo $ref; ?>
```


----------



## namenotfound (Apr 30, 2005)

What I mean is this:

In my comments box, they post an Amazon link such as:

http://www.amazon.com/gp/product/B00CRVL5XQ/

and MY (site owner) Amazon Associates referral tag is added to the link, such as:

http://www.amazon.com/gp/product/B00CRVL5XQ/?tag=eschultheiss-20

I've seen another website do this. People post Amazon links, and the site owners Amazon referral tag is automatically added.

I'm not talking about header referrals, I'm sorry if I wasn't being clear.


----------



## JiminSA (Dec 15, 2011)

Mmmm.... I'm stumped
Seems to be an Amazon thing... Have you asked on any of Amazon's forums?


----------



## COBOLdinosaur (Sep 9, 2001)

To create the actual link the script (server side) is generating the tagging by processing whatever form of BBcodes you are using. You just need to modify that scripting to detect that the link is to Amazon (or any other partner site) and add the referral sting to the end.


----------

