Clickbank on Drupal and all sites / blogs.. Contextual ads for affiliate programs!

Clickbank on Drupal and all sites / blogs.. Contextual ads for affiliate programs!

Hello there!
I have an account at clickbank but really can't be bothered to search the marketplace for relevant products for each of my pages, especially since I don't create the pages myself and don't choose the topics on my multi-users websites..

So I have used their HopAd Builder (under the ACCOUNT SETTINGS / HOPAD BUILDER navigation menu) it's a javascript widget which displays clickbank products related to the keywords you have specified.. Those keywords are in a variable in the javascript code they give you to put on your site. So to have contextual ads with clickbank it's only a matter of filling in this variable dynamically in PHP before returning the HTML source code to the user..

So, you get the idea, yes? But from what and how do you get those keywords?
Me in Drupal, for my very specific needs I have chosen to take:
- the node's title
- the category (taxonomy)
- the tags (taxonomy too, I want 10 maximum from there)

Here's part of the code I've used to take those 3 data and then clean everything, including deleting duplicate, deleting too short or too long keywords and make the final keywords as a comma separated list.. For sure the code is messy and probably does things which are not necessary, but I'm sure you can work it out, it's just an example, but I don't care to spend more time on this, but if you want to give your advise and opinion, feel free, I will read them carefully, don't worry when I say I don't care, in fact I'm talking about myself, but if someone is nice enough to spend a little time posting a comment, I read it and take it into account!

$mykeyword ="";
if (!empty($node)) {
 $mykeyword = $node->field_category[0]['view'];
 for ($k=0; $k <= 9; $k++) {
  if (!empty($node->field_tags[$k]['view'])) $mykeyword .= " ".$node->field_tags[$k]['view'];
$mysearchtitle = strtolower(strip_tags($node->field_toppagetitle[0]['view']));
if (!function_exists('normalization')) {
 function normalization ($string){
  $a = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿ';
  $b = 'aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyyby';
  $string = utf8_decode($string);    
  $string = strtr($string, utf8_decode($a), $b);
  $string = strtolower($string);
  return utf8_encode($string);

$mysearchtitle = str_replace("’", "'", $mysearchtitle);
$mysearchtitle = str_replace(Array("\"","'",",",".","/","(",")","[","]","*","-","+","!","?","@","#","$","%","&","_","=","{","}","<",">"), " ", $mysearchtitle);
$mysearchtitle = trim($mysearchtitle);
$mysearchtitle = str_replace("     ", " ", $mysearchtitle);
$mysearchtitle = str_replace("    ", " ", $mysearchtitle);
$mysearchtitle = str_replace("   ", " ", $mysearchtitle);
$mysearchtitle = str_replace("  ", " ", $mysearchtitle);
$mysearchtitle = normalization($mysearchtitle);
$mysearchtitle = mb_strtolower($mysearchtitle);
$mysearchtitlearray = explode(" ", $mysearchtitle);
$mysearchtitle = "";
foreach($mysearchtitlearray as $mysearchtitlearrayelement){
 $mysearchtitle .= $mysearchtitlearrayelement . " ";
$mykeyword = trim($mysearchtitle . trim($mykeyword));
// remove duplicate keywords, check that it is between 3 and 20 characters and not in black list words 
$mykeywords = array_unique(explode(" ", $mykeyword));
$mykeyword = "";

foreach($mykeywords as $onekeyword){
 if( (strlen($onekeyword) >=3) && (strlen($onekeyword) <=20) && (!in_array($onekeyword, Array("best","top","review","reviewer","reviews","before", "but","for","from","into","like","off","onto","per","since", "than","the","this","that","via","with","and"))) ){
  $mykeyword .= $onekeyword . " ";

$mykeyword = strtolower(trim($mykeyword));
$myoutput .= '<div style="position: relative; top: 0px; left: -40px;text-align:right;">';
$myoutput .= "
<script type=\"text/javascript\">
    hopfeed_font='Verdana, Arial, Helvetica, Sans Serif';
<script type=\"text/javascript\" src=''></script>
$myoutput .= '</div>';

And then I can simply do echo $myoutput; where I want to display the widget..

Of course this way is the best I've found so far, but ideally it would be nice to have from clickbank a list of clickbank products in XML or something, and then we can play with that as we want, for instance dynamically create links from within our text content.. But I couldn't find anything like that.. So I asked them the question..
I guess we could possibly do it, by trying to hack their javascript answer and then parse it and scrap the links to the products.. But honestly I haven't looked further, if you have links to people who offered code to do that, please send them in the comments, I'll add them to the post!

Here's a question I've sent to Clickbank, I'll let you know about their answer when I get it...
Hello, I use the hopad builder and I dynamically generate a list of keywords from each of my pages, to make it display relevant products for each page topic. It works more or less ok..

I would like to know if I could have a list of products send back to me in PHP rather than have to rely on a javascript hosted on your servers?

I'd like to know if you have an API of some sort, or just a web service that I can send a request to and get in response a list of related products, so I can display them exactly as I want, even dynamically create links in my content to link to those products, that would be way better than a javascript widget.

Thank you.

Here we go, I got an answer (thank you Clickbank for replying, that's appreciated) but unfortunately it is negative:
Hello James,

Thank you for your inquiry! Unfortunately, ClickBank's system does not have the advertisement creation options you have suggested. There is no API or webservice available to dynamically create links or ads in your content. The only automated ad feature available is the HopAd Builder.

I have forwarded this suggestion to the appropriate branch of ClickBank's Development Team so the merit and challenge of the proposed changes can be assessed. Any changes will be announced in the News section of the Account Home page of your ClickBank account. Please check often for updates of new releases!

Please let us know if we can be of further assistance!

Thank you,

ClickBank Client Support

After 3 weeks with no news from Clickbank, I received a message saying they're closing the support ticket, so I guess we'll never get an answer to know if they're working on an API at least:

Since I have yet to receive a reply I am going to go ahead and close this ticket. If you have further questions or if your questions remain unanswered, please feel free to reopen the ticket.

So I've played with the words in the text and replied a useless text:

Well, I guess the appropriate branch of ClickBank's Development Team forgot to give you their opinion on the merit and challenge of the proposed changes. I'll then monitor the news section of my account home page in my clickbank account for any update of new releases.
Thank you for having tried to get an answer.
Have a nice day.

So we can only hope that one day they will offer it. What could be done in the meantime is to download their big XML file which is updated daily and has all products. So we could put all those information in a database, use the description and title of each products in order to create our own keyword matching system..
Yes that would be possible and would be nice, but I'm not up to the task, because I'm too lazy unfortunately.

Once again if you have some tips about achieving this, maybe someone else provides such a webservice for free.. Share it.. Don't be egoist please :-)

Of course now, this tool

Of course now, this tool doesn't exist anymore at clickbank. But you can find alternative tools.

The problem I've found is that this simply doesn't work for the type of sites I have : general topics sites..

If you have a targeted site, then you'd be better off selecting a few good affiliate products for your topic and display them on your pages..

I tried and failed. I did read about people trying and failing too, but I wanted to try by myself to be sure. Now I know :-)

thanks ....

thanks ....

Similar Posts

eXTReMe Tracker