Short Amazon affiliate links – a bookmarklet
It's a pain to link to a specific product on Amazon if you have to use their UI to build an affiliate link. It's good to have nice, clean and short affiliate links. This post gives you the details and also a bookmarklet to built the links by visiting the product page you want to link to.
Anatomy of an Amazon affiliate link
Let's see the anatomy of a link in its shortest possible form.
Basically you have:
http://www.amazon.com/- self-explanatory, I think/dp/- standing for "details product" or maybe "details page"/1847194141/- a 10 character product code, aka ASIN code, Amazon Standard Identification Number?tag=affiliatecode-20- your affiliate code, or tag
For example my Amazon affiliate code is w3clubs-20, and an affiliate link to my book would be:
http://www.amazon.com/dp/1847194141/?tag=w3clubs-20
Amazon also uses longer search engine friendly URLs containing the book title, like:
http://www.amazon.com/Object-Oriented-JavaScript-Stoyan-Stefanov/dp/1847194141/?tag=w3clubs-20
But the book title/product name doesn't really matter, so this is fine too:
http://www.amazon.com/War-and-Piece-by-Stoyan-Stefanov/dp/1847194141/?tag=w3clubs-20
So I went ahead and created a bookmarklet that lets you visit the product page you want to link to, click the bookmarklet and copy a short affiliate URL.
Install the bookmarklet
Drag the link below to your favorites/bookmarks or right-click and add to favorites. Then right click the new bookmark and change its properties, replacing my Amazon affiliate code "w3clubs-20" with yours.
After installing the bookmarklet, just go to any Amazon product page, click the bookmarklet and it will create an affiliate link for you to copy.
The bookmarklet code, readable version
Here's the code for the bookmarklet, simply find the ASIN (product code) and build a new URL with it.
(function(){ var aff = 'w3clubs-20'; if (!document.getElementById('ASIN')) { alert('Can\'t find the product ID'); return; } var asin = document.getElementById('ASIN').value; prompt( 'Here is the link:', 'http://www.amazon.com/dp/' + asin + '/?tag=' + aff); })()
Misc
There's a page in the Amazon affiliates section that let's you check if the links are OK, it's here
Sometimes you might see (usually for non-book products) URLs that instead of /dp/ have /gp/product/, but if you build /dp/ links it's totally fine, according to their link checker, see previous paragraph.
This entry was posted on Sunday, October 19th, 2008 and is filed under AWS, bookmarklets, JavaScript. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
Get notification for future posts: follow me on Twitter or subscribe to my RSS feed

January 22nd, 2009 at 6:02 pm
Thanks for the bookmarklet. It is really useful.
May 10th, 2009 at 3:27 pm
I would like to add that this worked for me
http://www.amazon.com/gp/product/0340859490?tag=SOME_AFF_ID
this is linking to a product by ISBN (10 chars)
June 11th, 2009 at 3:46 am
Works for me, too. Thanks for a nifty little tool.
July 6th, 2009 at 12:10 pm
Will this work for MP3 links that use flash? They are over 500 characters.
July 8th, 2009 at 11:49 am
For several years, I have asked Amazon for help on making a shorter link, such as might be cloaked in some fashion. They never told me about the short form you describe.
Since your short form lacks parameters in the standard generated link, do I safely get sales credit?
July 8th, 2009 at 11:59 am
By the way, how do I use your code example?
July 8th, 2009 at 2:11 pm
Should be fine with the sales credit, but do test, don’t take my word for it.
To use the code, check the “Install the bookmarklet” section of the post.
Let me know if you have any troubles.
Thanks,
Stoyan
July 8th, 2009 at 4:02 pm
Still not complete understanding of script, but can do manually.
Thanks.
July 12th, 2009 at 2:50 am
[...] [From: Short Amazon affiliate links - a bookmarklet / phpied.com] [...]
September 6th, 2009 at 11:02 am
Here we are Abercrombie & Fitch Clothing retailer,sell a lot of abercrombie clothing, there may be many products suitable for you.welcome for you to come!
September 8th, 2009 at 1:08 am
Works great for me,
Thanks for that, it has saved me a lot of time
Paul Bright
October 26th, 2009 at 1:56 am
it works great and goes to the proper page but when i check it at the amazon link checker i get this:
Link Tagging Results
Fail: The link above was not tagged or was not a valid Amazon link.
how will this effect getting commissions?
December 13th, 2009 at 4:56 am
Works for me when I change the affiliate tag to my own. If you’re getting the ‘fail’ message, be sure that you’re entering your associate tag or sub-tag correctly. I received that message when I spelled my tag incorrectly, but received the success message after fixing the spelling error.
January 4th, 2010 at 10:39 pm
Genius! Thank you thank you, I think this will put years on my life.
April 14th, 2010 at 11:10 am
I feel silly asking this, but when I check my link, it looks like it’s taking people shopping under my name —- the page says welcome Christine at the top. Is that correct?
May 14th, 2010 at 10:52 am
Is it possible not to use node and associate tag as a parameters (not to use “?” and “&” characters in URLs) and still be able to link to the proper Amazon nodes like toys and games, or others with correct associate tag?
September 29th, 2010 at 5:39 am
Lovely. You saved me a bit of coding just now. :-p
December 4th, 2010 at 2:53 am
so far the best affiliate program for me is Amazon Affiliate. they have high tier rates and great payout ,;-
December 5th, 2010 at 7:44 am
I don’t know now how many format we can do but I normally do this format dp/asin/tag. short and easy for me…
December 15th, 2010 at 5:58 am
Hi
I understand the concept of it but some how it will not work on my site. I will try again later using james method.
Great post
Happy Holidays
January 9th, 2011 at 1:20 pm
Do you really need the
?tag=
part? When you delete that part, it still goes to the dp page. However, I don’t know if it really tracks the link.
As anyone verified that it works with the ?tag= part in it?
February 27th, 2011 at 8:02 am
Is your bookmarklet still up to date as I would like to use it. Unused to html, just want to get a link to Amazon, which seems so much more difficult than when I add other affiliate codes on my webpages.
March 8th, 2011 at 3:00 pm
Can you tell me how to install this for Google Chrome?
March 9th, 2011 at 1:37 am
Hi Stoyan,
Thanks for the bookmarklet, its really useful.
However, by any chance you’ll do an update of a shorter url since amzn.com now works, perhaps an automated script to churn it out would be great? Thanks.
May 29th, 2011 at 3:36 pm
I have to acknowledge this is actually 1 excellent understanding. This certainly provides organization the chance to obtain within on the floor ground as well as truly be a part of making some thing unique as well as customized for their requirements.
June 7th, 2011 at 12:46 pm
Nice tool! I was planning to implement similar tool to generate affiliate link. Thanks.
June 29th, 2011 at 3:53 pm
Thank you for this tool! I am updating all my old extremely long affiliate links now!
August 22nd, 2011 at 1:22 pm
It is actually a great and useful piece of information. I am happy that you simply shared this helpful info with us. Please keep us up to date like this. Thank you for sharing.
September 29th, 2011 at 1:20 pm
I hate the complex URIs generated for Amazon Associates by the Amazon scripts, so this simplified version is very helpful.
You mentioned the longer-form base URI that includes a hyphenated version of the product title, which is an aspect I always like to include in the links I embed in my blog posts.
I’ve never written any Javascript before, but a little browsing around and using the Firefox Web Console, I believe the following variation on the script you provide, substituting
document.getElementById(‘ASIN’).baseURI
for
‘http://www.amazon.com/dp/‘ + document.getElementById(‘ASIN’)
should do the trick.
Here’s the complete JavaScript bookmarklet, modified from the Amazon aff bookmarklet code you provide above:
javascript:(function(){var%20aff%20=%20′w3clubs-20′;%20if%20(!document.getElementById(‘ASIN’))%20{alert(‘Can\’t%20find%20the%20product%20ID’);%20return;}%20prompt(‘here%20is%20the%20link:’,document.getElementById(‘ASIN’).baseURI%20+%20′/?tag=’%20+%20aff);})()
September 29th, 2011 at 1:21 pm
Oops, forgot to include the “value” method from the original code. That substitution should have read:
document.getElementById(‘ASIN’).baseURI
for
‘http://www.amazon.com/dp/‘ + document.getElementById(‘ASIN’).value
November 30th, 2011 at 1:38 am
thanks, this is very useful information
December 14th, 2011 at 5:30 am
So what’s the latest…
Is there an Amzn update for this?
Do people still get the credit for the sale using your tool?
I see this was created 2 years ago… anyone test this recently?