Forum Moderators: open

Message Too Old, No Replies

Am I over-engineering this?

Using jQuery to parse affiliate links

         

caribguy

5:55 pm on Apr 30, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm starting work on my affiliate project once again, after it's been on the back burner for some months.

My original code would use a small external js to parse product and referrer id in order to launch a popup window. While thinking about usability for js inhibited browsers and my ability to extend the code in the future, I'm now considering to change the way my affiliate links are generated. The actual end result would still be similar (I may want to use a modal window rather than a popup).

What if my external script would load the jQuery framework and the affiliate sites would use a specific class name for their links to my product pages? This would make things simpler to implement for them, and still enable visitors who have disabled js to visit my site. Compare:

<a href="#" onclick="myFunction('productid', 'affiliateid')">Buy this widget</a>

<a class="affiliate" href="http://www.example.com/productid/affiliateid">Buy this widget</a>

The main advantage is that natural links are preserved without having to duplicate the code. There may also be some link juice benefit, I would of course allow webmasters to nofollow these, but don't expect all of them to do so...

Am I making things too complicated?

daveVk

11:37 am on May 1, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Third alternative

<a onclick="return myFunction(this);" href="http://www.example.com/productid/affiliateid">Buy this widget</a>

MyFunction can mine href for details.

Wondering if jQuery is too big an overhead, or likely to crash with frameworks client may be using.

caribguy

5:28 pm on May 1, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm now loading JQuery with LABjs, adding my styling to the links and a div to the affiliate page for the modal window. All in one go. I must say it looks really spiffy :)

The overhead is 80K or so. I figure if I use a CDN, the impact would be even less. Testing on an old AMD Sempron, not noticing any hiccups yet.

One feature I didn't realize I could use (seems obvious now) was $('#window').load() - this could allow visitors to navigate through my site and keep the whole registration/validation process in that same window until the transaction is completed.

caribguy

6:50 pm on May 1, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Re-reading your comment, having another 'duh' moment:
MyFunction can mine href for details.

And any link that refers back to a product on my site could be treated as an affiliate link. I'll let jQuery modify the behavior, doesn't even need MyFunction(). Makes it extremely easy for any webmaster to implement...

Also going to check if the include could be placed in the body of a document rather than its head section.

Thanks!

caribguy

11:18 pm on May 2, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If there's any interest, I could keep documenting my adventure. Today, I'm looking at various ways to get around same domain limitations.

Rather than using iframe or Flash, I'll first take a look at jQuery.getJSON()

If it turns out that I have to reformat my data too much, I'll probably end up with Flash and dynamically generating my crossdomain.xml file.