Spoof Affiliate Link Destinations 1

Spoof Affiliate Link Destinations

Note: This post is probably better on desktop where this consideration could make a difference. Watch the GIF.

When reading blog posts from other affiliates I subconsciously keep an eye out for this sort of thing:

Affiliate link example

See that text box that appears in the bottom left when I hover over an affiliate link? It’s nitpicky, but I bet it’s something more seasoned internet users are used to doing. Today we’re going to spoof it so that the destination linklicious.co appears onhover, rather than ohgm.co.uk/nope/linklicious.

Something like this:


Click the link, watch the headers.

Going by the status bar, the above link appears to lead to ‘linklicious.co’. Viewing the HTTP headers we can see that it actually goes through a redirect on this domain first. This would fool the majority of internet users.


Originally I’d tried altering the text which appears with this:

<a id="anchorID" style="cursor:pointer;">great deal here</a>
$("#affiliate").click(function() {

You can try this out here. I’m actively bad at JavaScript, forgive me. Researching around, I came across this simpler method from Owen Boswarva:

Which works perfectly.
Which works perfectly, in isolation.
<a href="http://www.google.com/" onclick="this.href='http://news.bbc.co.uk/'">THIS LINK</a>

Unfortunately we’re on WordPress here, and WordPress does not like JavaScript within posts (it strips it out for reasonable reasons). This is frustrating if you want to jump straight into tricking savvy users into clicking your affiliate links.

Get WordPress Doing This

Rather than edit functions and using our brains, we’re going to install a plugin. The one I’m using here is helpfully called ‘Code Embed‘. It allows us to embed code using custom fields in WordPress.


So in our post we create a custom field using the method above:


Wherever we include the Name of the custom field between two ‘%’ symbols, the plugin will insert the HTML & JavaScript without editing our code.

Disable External Link Tracking

Unfortunately there’s a hitch. Monsterinsights (formerly Yoast Analytics, which I know many of you run) overwrites it so that it doesn’t work. Here’s the actual output when both plugins are running at once:

<a href="http://linklicious.co/" onclick="__gaTracker('send', 'event', 'outbound-article', 'http://linklicious.co/', 'linklicious');" onclick="this.href='https://ohgm.co.uk/nope/linklicious'">linklicious</a>

Monsterinsights is adding an onclick event to all external links to track them. This invalidated the onclick event we want to append, meaning your affiliate offers would be bypassed entirely.

Increased CTR without the possibility of conversion.

The solution for the purposes of me getting this post out is to disable this option in Monster Insights:


I understand that this will be a deal-breaker for some people. Tracking is really  important to people with good websites. I’m sure some of my smarter readers can have both.

This isn’t very TAGFEE

This is actually less deceptive than the process most affiliates already employ (a link to a redirect hosted in a folder blocked in robots.txt). Redirects are not transparent (they could go anywhere) –  here we’re at least being honest about the domain we’re sending them to (just not the full URL with the affiliate query parameter).


This could be used for obviously  deceptive ends . Have fun!

This will harm conversions more than help them (seriously), so I won’t be implementing this anywhere until the glaring issue I’m thinking about is resolved. This is also clearly terrible SEO.

Comments below!

2 thoughts on “Spoof Affiliate Link Destinations”

  1. Okay, so this is great. I love how you use your affiliate links. I mean, it’s kind of like an easter egg for loyal readers, isn’t it? /nope/

Leave a Reply

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