Proposal: all Amazon hyperlinks get Less Wrong's Amazon Associates referral code

My site, which gets slightly less traffic than Less Wrong, makes me $50-$200 per month with Amazon referral links and no advertising at all. I don't profit this way, but I recoup some of my costs.

I think the Less Wrong audience is much more likely to purchase books - including expensive textbooks - than my audience is. And it would be easy to automatically transform all Amazon links on Less Wrong so that they include a Less Wrong Amazon Associates referral code, which would make Less Wrong some money on every purchase made through one of those links.

Below is the pseudocode, assuming Less Wrong's Amazon Associates referral code is "lesswrong". Note that every Amazon page for an item contains at least the following string: "/dp/XXXXXXXXXX/" where XXXXXXXXXX is alphanumeric.

if hyperlink contains "**/dp/??????????/" then change hyperlink to ""

That's it! For example, let's say somebody wrote a post and pasted in the following Amazon hyperlink from their browser's address bar:

This would be transformed into:

This is precisely what I do on my own site. Works like a charm. If somebody clicks my book link but ends up buying a $1000 DSLR instead, I get about $65 for that one purchase.

Somebody who didn't give up programming in 8th grade could do this fairly easily I imagine, and it would help cover Less Wrong's expenses.

20 comments, sorted by
magical algorithm
Highlighting new comments since Today at 2:08 AM
Select new highlight date
Moderation Guidelinesexpand_more

This is already being done on Less Wrong!

Back in August 2010, I helped install an even more universal solution in the form of VigLink to experiment and see if it would work well for us. These are our recent earnings so far... I think all from Amazon:

Aug 10: $0 Sep 10: $0 Oct 10: $1 Nov 10: $1 Dec 10: $12 Jan 11: $37

Also, I think we actually make more by paying VigLink's fees since they get paid the top-end volume bonuses by Amazon and then pass that great rate on to us (less their fees). It's really close though. I'll worry more about optimizing it when we're getting more commissions.

It looks like LW's Amazon affiliate code is "vglnk-c319-20". I missed it earlier because apparently VigLink doesn't work if you control-click on a link to open it in a new tab. I've written a Chrome/Greasemonkey user script you can install to add the affiliate code to links you click on other web sites, as well as if you go to manually.

Does that mean I should click through from less wrong before all my amazon purchases? Or does it only work if the exact book I'm purchasing was linked from Less Wrong?

Yes, clicking a LW Amazon link before buying things from Amazon is very helpful. It will give ~6.2% of the purchase price on whatever you end up buying back to LW.

Right. You don't need to buy the exact item linked to. Just purchase during that same Amazon visit, an LW will get a cut. Free money for LW!

As Wei Dai reports, VigLink does not work when you open the link in a new tab or window.

Also, it does not work for me at all in Firefox. I have NoScript installed, but have white listed every script domain on Less Wrong (including except It does work for me in IE and Chrome.

If anyone else is wondering about that huge ramp-up, viglink's faq suggests that it is mainly due to a 90 day delay of actually receiving the money (not special to viglink). Plus affiliate cookies may last 30 days, though I'm surprised that's relevant to amazon.

Some old EY writings indicate that there is/was an Amazon Associates account called "singinst", but I'm not sure if that's still active or being used. But using that would be better than nothing, in the meantime. (I notice that none of SIAI's suggested reading pages use it, which they really should... unless perhaps there's some legal or TOS problem with a charity raising money through affiliate sales; anyone have any experience or information regarding that?)

Some Googling shows a lot of nonprofit charity sites and blogs with ads.

This function will inspect a url and if it is a well formed amazon product url it will modify it to use the given affiliateId, and if it is not, it returns the url unchanged.

I am assuming that the code base knows when there is a url (which should be part of the implementation of mark down). Is there anyone more familiar with the code base who could use this function to make the proposed feature? Also we still need to know what affiliateId to use, which should probably be configurable by an administrator.

import urlparse;

def SetAmazonAffiliate(url, affiliateId):
    uri = urlparse.urlparse(url);
    address = uri[1];
    if ((address.lower() == "") | address.lower().endswith("")):
        path = uri[2];
        i = path.find("/dp/");
        if (i < 0):
            return url;
        i = path.find("/", i+4);
        if (i < 0):
           return url;
        return uri[0]+"://"+address+path[:i+1]+"ref=nosim?tag="+affiliateId;
    return url;

Semi-colons in python code? That just looks wrong.

I am not a native python speaker. I am used to C#, Java, and (when I have to) javascript, which all require/encourage semi-colons.

Re-reading my comment it seems harsher than I'd intended. You did the work to figure out the code so someone can just plug it in, where I did nothing at all. It was merely meant to be a tip, so I hope it didn't offend.

It's not true that Amazon product URLs must contain "/dp/". According to , product URLs may have the following formats:

Which is not even a complete list because I've also seen:

Instead of trying to parse all these formats, I suggest just adding "?tag=lesswrong-20" or "&tag=lesswrong" (depending on whether the URL already contains a "?") to the end of every URL. Also, "ref=nosim" is obsolete and can be omitted.

Sounds great, I'd happily click on a Less Wrong referral link before my amazon purchases!

Experience shows that making this proposal doesn't do anything. ETA: but those are all in comments. Maybe this higher-level post will have an effect.

I think that search produced a lot more results six months ago. Changing the word order produces many more results, including some relevant ones.

You might want to consider how this interacts with, etc. I'm assuming associate references don't carry over from one site to the other, as logins/sessions/cookies won't.

My site, which gets slightly less traffic than Less Wrong, makes me $50-$200 per month with Amazon referral links and no advertising at all. I don't profit this way, but I recoup some of my costs.

My own experience is similar. Over the year I've had Amazon referral links on's existing Amazon links, the average monthly income has been $45.

(I'm not sure traffic-wise how LW & my site compare, but the Alexa US ranks are 60841 & 100008 respectively.)

The code looks mangled after the "??????????".

Yeah, it's psuedocode. Just saying what needs to be done rather than actually executable code.

Inform, a language for writing text adventures, is interesting in that it's only small quirks of vocabulary and syntax that let you know the actual code from some hastily jotted down pseudocode