Some time ago we wrote about making older WordPress sites mobile-friendly with WPtouch. The examples we referenced in that post were a couple of publisher sites built back in 2010. These sites were set up to scrape product feeds from an affiliate network and automatically generate posts for all products in the feed. More than 10 years later and technology has moved on like we couldn’t imagine. However, the general principles of how we put these type of sites remain the same or at least very similar. We take a product feed, parse it into a holding table and then automatically generate posts with it. The difference this time is we would use WooCommerce to power the front end. This would result in a site that looks much more like you’d expect an ecommerce site to look. Here we talk you through the process in more detail.
What exactly is affiliate marketing?
First, we need a product feed. Actually, we’re getting ahead of ourselves… first we need a publisher account on an affiliate network. We could go into detail about the various options here and to a certain extent, it depends if there is a specific retailer you want to promote. In that case, you would need to find out which network they were on and register with them. You’d then have to join the retailer’s program and that’s by no means guaranteed. Some retailers will not work with certain types of affiliate and they are definitely much more selective nowadays. For anyone who is not familiar with the concept of affiliate marketing, it is the process of earning a commission by promoting a retailer’s products or services. This is normally by taking a percentage of the profit for each sale that you help make.
Setting up your affiliate product feed
Okay then, back to the product feed. All the affiliate sites we have built are on the Awin network or Affiliate Window if you’ve been in the business long enough to remember them before the abbreviation became the name! Why them? Over 2 million products are available for inclusion in product feeds. Awin’s Create-a-feed tool allows you to generate feeds in CSV, XML or JSON format. It also allows you to choose by product category, by advertiser or by brand. It’s therefore extremely easy to tailor a product feed for your particular niche, in our case ‘everything baby‘. Once you’ve configured your product feed, you’ll end up with a feed URL like the one below. The site was designed to be the number one resource for finding baby related products online. Pushchairs, car seats, nursery furniture and playtime and as our tagline says “We can help you with everything baby!“
Integrating your product feed
The product feed URL is basically what determines the products that are returned to you and the format of the feed. Once we have that, we can plug into our own scripts, which can in turn do all the hard lifting. At a very high level, the first script calls the product feed URL and then decompresses it because we are using Gzip to make the product feed smaller and therefore quicker to process. It then loops through each line (we use CSV format for simplicity) and dumps to a database table. Note, this is a table in the main WordPress database, but it doesn’t follow any WordPress conventions, nor do our scripts follow WordPress coding standards or are integrated in any way. This scraper script as we call it, runs every 4 hours, adding or updating products in our database as required.
Creating your products in WordPress
The next stage of the process is to take that data and import it into WordPress. It used to be that we would create a post for each product, listing its description, price and any other key attributes, finally adding to a category, which might be the product’s brand or department depending on the site. With WooCommerce, it is slightly different though as we want to create as an actual product within WordPress. We do this by posting the data via the WooCommerce REST API. One last thing to mention here… when importing the product, we specify an external URL and button text and it’s this that makes WooCommerce aware that the product is an external/affiliate one.
Well that’s just about that, certainly in terms of the product integration anyway. For this site we used a free theme called LT Baby Shop from LT Themes, built on the Genesis Framework by StudioPress. We also used many of our usual go-to set of plugins, plus a few new to us that came bundled with the theme. All in all a neat little project to work on and keep us busy.
If you have any requirements for upcoming WordPress projects, however big or small, then speak to our team today to discuss.