Amazon Affiliate Link checker – tool

It’s a terrible name for a tool. I know..

However it does the job though. Quite often I’ve seen people ask me whenever I’ve sold them a site: “How will I know I changed all the links?”. Because if you leave a tag unchanged on your site, that affiliate sale won’t be going to you..

The mechanics..

For those of you who are not familiar with how affiliate marketing works the above will’ve sounded like hebrew.

Affiliate marketing works in such a way that you push traffic to a site. That site then pays you for the traffic you have sent, should that traffic make a purchase.

I’ll just use amazon as an example as it seems to be the most popular affiliate platform.

So if I send someone through my website to Amazon and should that someone buy something from Amazon, I make a little bit on that sale. That’s how the economics works.

Now your next question should be: How does Amazon know that that person came from your site?

Good question!

Affiliate links

Here we come to the root of our problem. Affiliate links is how amazon keeps track of who came from where. And, more importantly, who to pay what and how much.

Every product mentioned on any niche site pushing people to Amazon uses affiliate links.
These are normal amazon product links, with one difference. These links contain tags that Amazon registers to each individual niche marketer.

So if you buy an already operational niche website that is making money, it’s in your best interest to change all tags in the affiliate links to your own.

However up until now you had to manually sift out the links from the page and just hope you got them all.

With this new tool I made, you can check a URL; It’ll then show you all amazon affiliate links on that site with its anchor text AND it shows who’s tag is attached to it.

So if you see a tag you don’t recognize, simply search for the anchor text of that link and change that link to a link that has YOUR tag.


For the ones who want to know how I did it:

It’s a small php script I have running that parses a certain URL for links:


$html = file_get_contents($url);

//Create a new DOM document
$dom = new DOMDocument;

//Parse the HTML. The @ is used to suppress any parsing errors
//that will be thrown if the $html string isn’t valid XHTML.

//Get all links. You could also use any other tag name here,
//like ‘img’ or ‘table’, to extract other tags.
$links = $dom->getElementsByTagName(‘a’);

//Function to check for shortened URL’s
function unshorten_url($url) {
$ch = curl_init($url);
curl_setopt_array($ch, array(
CURLOPT_FOLLOWLOCATION => TRUE, // the magic sauce
CURLOPT_SSL_VERIFYHOST => FALSE, // suppress certain SSL errors
return curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);

//make it look nice
echo ‘<table>’;
echo ‘<tr class=”header”>’;
echo ‘<td style=”vertical-align:center; font-weight:bold;”>Anchor text</td>’;
echo ‘<td style=”vertical-align:center; font-weight:bold;”>Amazon tracking code</td>’;
echo ‘</tr>’;

//Iterate over the extracted links and display their URLs
foreach ($links as $link){
echo ‘<tr>’;
if (strpos($link->getAttribute(‘href’), ‘’) !== false || strpos($link->getAttribute(‘href’), ‘’) !== false) {

//Check for non-existant anchor text, most likely an image link
echo ‘<td>’;
echo “IMAGE LINK”, “\n”;
echo ‘</td>’;

echo ‘<td>’;
echo $link->nodeValue, “\n”;
echo ‘</td>’;
$parts = parse_url(unshorten_url($link->getAttribute(‘href’)));
parse_str($parts[‘query’], $query);
echo ‘<td>’;
echo $query[‘tag’];
echo ‘</td>’;
echo ‘</tr>’;
echo ‘</table>’;
echo ‘</br>’;
echo ‘</br>’;
echo ‘<a href=””>Go try another link!</a>’;


Happy link hunting!



edit: Already I’ve seen a few additions I could do to this tool. It could also check if the link is still working. Meaning that is the product still existing in Amazon/check for 404’s…

So many ideas!

Leave a Reply

Your email address will not be published. Required fields are marked *