Bibli.nl

Peter's blog about cruft and more

18 December
1Comment

Drupal and affiliate marketing

In this post I will explain how you can combine the content management system Drupal with affiliate marketing tools. In the past http://www.bibli.nl was a website showing nodes from several XML feeds containing audio books and magazines. I created this functionality with some custom modules, but often it is better to stick with a combination of community modules to reach your goal. In this case the goal is to import items from a affiliate feed as nodes using contributed modules. But how can we achieve this?

Requirements

To reproduce the steps in this article you will need at least the modules that are listed below.

Optional you can use Feeds Xpath Parser if you want to use Xpath to extract data from the XML feeds.

Step 1: Choose an affiliate marketeer

With bibli.nl I used the Dutch program Daisycon, but other programs such as Netaffiliation or M4N are also fine. Of course there are more programs but I’ll use Netaffiliation as an example. With these marketing tools there are often a great number of advertisers that only offer text-links or banners. We’ll need an advertiser that uses XML feeds or CSV files to share their product information with us.

Step 2: Get the feed

Catalogue of Netaffiliation / Teatower.nl

Catalogue of Netaffiliation / Teatower.nl

As you can see at the screenshot the feed contains a large number of fields and I can choose to recieve the feed in XML format or using comma separated values (CSV). At the bottom of the page is an URL (that you can not see in this screenshot) where we can access the feed. I’ll start simple by using a CSV file.

CSV file from Netaffiliation

After visiting the URL of the feed you’ll be able to download the file and take a look at it. As you can see Netaffiliation is French, but the names of the columns shouldn’t be a problem because the are explained when hovering over the column names in the catelogue view. Af few examples:

  • Nom == Name
  • Prix == Price
  • Monnaine == Currency
  • Idneta == unique product identifier of Netaffiliation
  • … and so on.

Step 3: Prepare Dupal

Creating content types in Drupal

Creating content types in Drupal

In Drupal I created two content types. The content type ‘product’ is meant as the result after importing the feed. This content type is enriched with the field ‘price’. You can add more fields as you see fit. I will only import very basic fields such as title, description, price and keywords. There are CCK modules such as FeedAPi Imagegrabber that will help you grab other fields such as the images mentioned in the feed. The second content type is ‘Feed’. After configuring the settings from the Feed module I’ll be able to import multiple feeds using a node as basis.

Step 4: Configure the Feed importer

The next step is to configure the feed importer. This will consist of several small steps. Go to Home › Administer › Site building › Feed importers and create a new importer. After inserting some meaningful names you can get started with the configuration.

Basic settings of the feed importer

Basic settings of the feed importer

At the basic settings form you can set how often the FeedApi should pull from the URL. This setting depends on the refresh rate of the content of the advertiser. If the feed is large and the refresh rate is low then 30 minutes is definitely wrong. But for example purposes I’ll leave it as it is. As you can see at the screen shot this is also the place where I define the content type “Netaffiliation Feed” as a place holder for the URL of the feed(s).

Fetcher Settings

Fetcher Settings

The Fetcher settings determine how the Feedapi receives the content. Default it is possible to use an upload of a file or fetch the content from an URL. Of course we’ll go for the lazy way and use the ‘http fetcher’. After selecting the ‘http fetcher’ you can alter the settings, but I kept all check-boxes turned off.

CSV parser

CSV parser

Next step is to choose the parser. We’ll use a CSV file so we’ll have to use the CSV parser. At the settings page of the CSV parser you can set the delimiter. I use ‘;’ but this can differ per CSV file. If the feed doesn’t start with a row of headers you’ll have to set the check box. The names of the header will be used for mapping the column to node fields.

Node parser

Node parser

At the next step you can choose the parser. I selected the node parser. At the settings form of the parser we can save the items from the feed as ‘products’ and select the default author. Also important is the setting how you want to update existing nodes. Choose what fits best with your situation. Start simple and improve the process later.

Mapping CSV columns

Mapping CSV columns

The last step is the mapping of the CSV header columns to Node fields. In the screen shot you can see how I mapped some of the headers to fields. It is important to have a unique identifier if you want to be able to update existing nodes. If you don’t have headers, you’ll have to use numbers to select the right column. In my case ‘name’ would be column 5.

Step 5: Import the products

Create a Feed node

Create a Feed node

The last step is to create a feed-node. Fill the title, description and URL and save the node. Now Drupal should start importing the nodes. And in my case 906 nodes were created. If you want to delete those you can go to the feed-node and select the local task ‘Delete items’ or use a module like Bulk Delete.

Step 6: Conclusion

Product node

Product node

This is the result: one of the 906 nodes containing a title, body, price and some keywords. But is there a downside?

Your import could fail due to delimiter character in the fields. The feed can contain unwanted characters. The data in the feed can be inconsistent and a ton of different other reasons.

So there are still situations that some programming skills are useful. By taking a look the Feedapi developers guide you can figure out how to interact with FeedApi when it tries to save a certain field. This way you can alter the input to your liking.

As mentioned before: CSV is just one way of solving things, using parsers such as Xpath, OPML, RSS or even site maps belongs to the possibilities.

 

One Response to “Drupal and affiliate marketing”

  1. [...] Dit blogartikel was vermeld op Twitter door Kindred Huber. Kindred Huber heeft gezegd: RT Drupal and affiliate marketing http://j.mp/eZWUBs. Using FeedApi is really nice and it is invented for lazy people! [...]

Place your comment

Please fill your data and comment below.
Name
Email
Website
Your comment