SEOmofo SERP Snippet

Advanced SEO for Affiliate Marketing Links

Affiliate marketing is primarily about two things: (1) acquiring traffic, and (2) converting that traffic. In my experience, I find that affiliate marketers typically focus more of their time on the conversion rate/click-through rate side of things. However, since I don’t know a damn thing about conversion rates, this article will address the “traffic acquisition” side of things by discussing some advanced SEO techniques I’ve developed specifically for affiliate marketers. Some of this information can be applied to banner advertising-based sites as well.

This article is going to get a bit technical. You’ll need to analyze my code examples and customize them to suit your needs. It’s not completely necessary to know JavaScript, but it will certainly help if you do. If you’re hoping to skim through this article in a few minutes…forget it. You won’t get anything out of it. If you’re hoping for some advanced SEO techniques for affiliate marketers that can minimize PageRank loss and make your pages load a lot faster, then you’re in the right place…but you’ll need to really pay attention. Grab a cup of coffee and then proceed.

Update: I wrote another post about the techniques mentioned in this post. It addresses the question of whether or not these techniques are permitted by the Google Webmaster Guidelines. Check it out: Using JavaScript to Hide Links from Google

Also, when I wrote that second post, I created a diagram of the SEO techniques mentioned in this post. If you are more of a visual learner, then I recommend you check it out: lazy-loading affiliate marketing anchors.

Common SEO Issues of Affiliate Marketers

Let’s start by looking at a couple of SEO-related topics that are relevant to a large percentage of affiliate marketing websites–PageRank and page speed.


There are a couple of different ways in which PageRank can affect the performance of your affiliate website’s rankings in Google’s search results. For one, you can hinder your rankings by bleeding your site’s PageRank through outbound links to affiliate URLs. Even if your affiliate links contain the rel="nofollow" attribute, there’s still a strong possibility that Google factors them into the calculation of the followed links’ PageRank.

In other words, just because the nofollowed links don’t pass PageRank to your affiliate URLs, that doesn’t necessarily mean your remaining links (i.e. the ones without the rel="nofollow" attribute) get a bigger slice of the PageRank pie. The mere presence of nofollowed affiliate links on your web pages might result in an overall loss of site-wide PageRank, a concept some of you may know as “PageRank evaporation.”

The second way that PageRank might affect affiliate marketing sites is less common, but much more severe, and it has to do with Google’s Webmaster Guidelines. One of the things Google (i.e. Matt Cutts) has said repeatedly is that paid links must not pass PageRank.

Now granted, paid links are not exactly the same as affiliate links, because theoretically (according to Google’s stupid reasoning) paid links are definitely NOT unbiased, editorial-grade endorsements of the linked content, whereas affiliate links might be. Personally, I’d rather avoid the issue entirely, by making sure none of my affiliate links pass PageRank.

Page Speed

As most of you know, Google has incorporated page speed into its ranking algorithm. This is bad news for any affiliate sites that rely heavily on image links and ad banners, because these resources typically slow down the loading time of your pages.

Affiliate Link Optimization

Here are the basic goals I set for myself when developing my super-advanced SEO technique.

Don’t Lose PageRank

As an SEO–the best in the world, as a matter of fact–my primary concern is avoiding the potential “evaporation” of PageRank that might occur as the result of nofollowed affiliate links in my page content. Therefore, my super-advanced SEO solution must NOT rely on the use of the rel="nofollow" attribute.

Don’t Pass PageRank

In order to comply with Google’s Webmaster Guidelines, my extremely-advanced SEO solution must prevent search engines from crawling my affiliate links or passing PageRank through them.

Follow the FTC Guidelines

The Federal Trade Commission published their Guides Concerning the Use of Endorsements and Testimonials in Advertising, an 80-page document that can be summarized in 3 words: disclose paid endorsements.

At least I think that summarizes it…honestly, I didn’t read any of it. My extra-super-advanced SEO solution should automatically identify affiliate links by applying some kind of unique styling or visual aid.

Don’t Slow Down My Page Speed

Affiliate-related content (links, images links, banner ads, etc.) must not delay the loading of my page content…at all.

Make it Degrade Gracefully

If you haven’t guessed yet, my über-advanced SEO solution is going to rely on JavaScript. Therefore, it should degrade gracefully in browsers that don’t have JavaScript enabled.

Also, it shouldn’t negatively affect accessibility. So to all you SEOs and affiliate marketers out there who are rockin’ screen readers or whatever…don’t worry, I gotcha covered.

Make it Easy to Use

A small percentage of my dear readers are actually “advanced SEOs”–or advanced anything, for that matter–and I can publish a loosely-defined solution, confident that they will tweak my code or improve on it, in order to meet the specific needs of their website.

However, the majority of you have the cognitive abilities of a small piece of driftwood, and for your sakes…my solution should be reasonably easy to implement.

My Incredibly-Advanced SEO Solution

Alright then, Woody, let’s dig in!

What You’ll Need

Here is a generalized list of the various files and page elements that we’ll be working with:

  1. external JavaScript file (e.g. scripts.js)
  2. external stylesheet (e.g. styles.css)
  3. robots.txt file (e.g. robots.txt)
  4. a web page that contains affiliate links

Step 1: Create the JavaScript

Paste the following JavaScript code into your external .js file. I have made lots of comments throughout it, in order to help you understand (and/or customize) the code.

Attribution: My code uses a utility function, called hasClass(), which is from the book JavaScript: The Definitive Guide, 5th Edition, by David Flanagan. Copyright 2006 O’Reilly Media, Inc. (ISBN: 0596101996).

show source

Step 2: Define the CSS Styles (Optional)

The following CSS code is an example showing how I have defined my affiliate links’ styles. You don’t necessarily have to use my styles; you can use your own if you prefer.

If you want to use this example, be aware that it assumes you have placed a cursor file, called affiliate-link.cur, in a directory called /cursors/ on your web server. If you save your cursor in a different subdirectory, adjust the URL accordingly in the CSS code.

Also be aware that this example assumes you have a 125px ad banner, called thesis-125x125.gif, in a directory called /banners/ on your web server. You will obviously need to customize the code so it references ad banners you’re actually using on your site.

You can use any cursor you’d like (perhaps one of these middle finger cursors?) or you can download a copy of the one I’m using, by clicking on it below.

To download this cursor, click here ⇒ Affiliate link cursor

01 a.affiliate {
02 color:#339900;
03 }
04 a.affiliate:hover {
05 cursor:url('/cursors/affiliate-link.cur'), pointer;
06 }
07 a.affiliate span {
08 display:none;
09 }
10 #thesis125 {
11 width:125px;
12 height:125px;
13 }
14 #thesis125 a.affiliate {
15 display:block;
16 width:125px;
17 height:125px;
18 background:url('/banners/thesis-125x125.gif') transparent no-repeat;
19 }

Step 3: Link Your Web Page to the External Files

Assuming your file names are styles.css and scripts.js, you would need to put something like the following code in the <head> section of your web page:

1 < link rel="stylesheet" type="text/css" href="/styles.css" / >
2 < script type="text/javascript" src="/scripts.js"></script >

Step 4: Block Search Engines from Viewing Your External Files

Google’s ability to crawl JavaScript links keeps getting better and better. However, in this case, the URLs are not actually in our web page’s HTML source code. The only markup Google will see is the empty <span;> tags.

In order for Google to find our affiliate links, it would have to fetch our external JavaScript file first. To make sure this doesn’t happen, you would need to Disallow your JavaScript file in your robots.txt file.

If you saved scripts.js in your site’s root directory, your code would look like this:

User-agent: *
Disallow: /scripts.js

If you saved scripts.js in a subdirectory called /nobots/, your code would look like this:

User-agent: *
Disallow: /scripts.js

Step 5: Insert the HTML Code into Your Web Page

The final step is to mark up your web pages. After the content of your web page is finished loading, the affiliateLinks() function will be called, and the <span> tags that have the affiliate CSS class will be injected with affiliate links. The next section has some mark up examples.

HTML Markup Examples

The following examples should give you a better understanding of how the script works. For each example, I will show you the HTML before (i.e. before the script modifies it), the HTML after, the final result with JavaScript enabledand the final result with JavaScript disabled.

Simple Plain Text Link

HTML Before:

2 runs on the <span class="affiliate" title="Thesis">Thesis Theme for WordPress</span>.

HTML After:

2 runs on the <span class="affiliate"><a class="affiliate"href="">Thesis Theme for WordPress</a></span>.

Result with JavaScript Enabled: runs (no longer) on the Thesis Theme for WordPress.

Result with JavaScript Disabled: runs on the Thesis Theme for WordPress.

Another Plain Text Link

HTML Before:

2    Find out more about my site's WordPress theme, by reviewing the <spanclass="affiliate" title="Thesis Plans">Thesis <b>plans and pricing</b></span>.

HTML After:

2    Find out more about my site’s WordPress theme, by reviewing the <spanclass="affiliate"><a class="affiliate"href="">Thesis <b>plans and pricing</b></a></span>.

Result with JavaScript Enabled:

Find out more about my site’s WordPress theme, by reviewing the Thesis plans and pricing.

Result with JavaScript Disabled:

Find out more about my site’s WordPress theme, by reviewing the Thesis plans and pricing.

Image Link

HTML Before:

2    <span class="affiliate post-ad-right" id="adobe300x250" title="Adobe 300x250"></span>
3    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus vel lorem ipsum, in vulputate purus. Nullam faucibus turpis vel ipsum vestibulum eleifend. Maecenas vel velit aliquet purus feugiat pellentesque.

HTML After:

2    <span class="affiliate post-ad-right" id="adobe300x250"><aclass="affiliate post-ad-right"href=""></a></span>
3    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus vel lorem ipsum, in vulputate purus. Nullam faucibus turpis vel ipsum vestibulum eleifend. Maecenas vel velit aliquet purus feugiat pellentesque.

Result with JavaScript Enabled:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus vel lorem ipsum, in vulputate purus. Nullam faucibus turpis vel ipsum vestibulum eleifend. Maecenas vel velit aliquet purus feugiat pellentesque.

Result with JavaScript Disabled:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus vel lorem ipsum, in vulputate purus. Nullam faucibus turpis vel ipsum vestibulum eleifend. Maecenas vel velit aliquet purus feugiat pellentesque.


The SEO techniques I’ve discussed in this article are best suited for affiliate marketers who work with niche sites. This is because the JavaScript example I provided contains a list of name/value pairs that tie the title attributes of the affiliate <span> elements to their corresponding affiliate link URLs. This kind of setup works fine for most people, but it doesn’t scale up very well.

Affiliate sites that link to a large number of different advertisers and/or products would find it impractical to constantly update their JavaScript file. In those cases, the script could be modified so that the function takes an obfuscated URL as it’s argument, and then decodes it before injecting it back into the HTML source. (Obfuscating the URL keeps Google from randomly picking it out of your HTML and crawling it.)

I’m planning on doing a follow-up article about advanced SEO for affiliate marketers. It will build upon the basic concepts in this article, by giving some examples that inject 3rd-party scripts, Flash objects, and iframes. Just to give you an idea of what’s possible with these techniques, I’ll leave you with a copy of the page speed test results of the page you just read.

If you’re not sure how to read this, then I’ll give you a hint: the green line indicates where the page begins to appear in the user’s browser, the blue line indicates where the page is officially loaded (i.e. where Google stops the “Site Performance” stopwatch), and everything to the right of the blue line is all the stuff I lazy-loaded after the onload event fired. Or in other words…this technique just cut down on my page load time by about 82%!!!

affiliate speed savings
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram