XML Feeds

A great way for an advertiser to share thousands of products with affiliates, comparison shopping sites, and marketplaces is to provide them with an affiliate data feed. This feed is a file containing specific information about their products and where to find them on their website.

Although most e-commerce solutions provide access to an XML data feed, they are not integrated with their affiliate tracking software. Thus, advertisers can’t share them with their affiliates. This article outlines the benefits of data feeds for affiliates. Providing data feeds to affiliates is the only way to help affiliates promote the right products on-the-fly.

XML Feeds

A data feed is a XML file containing details on the advertiser’s products. Each product is a new record in the file and includes the product name, description, URL, image links, categories, and prices. The information in a data feed may vary from advertiser to advertiser as there is no standard way of creating them. Having the feed of data return in an XML format provides a universal, easy to parse solution for affiliates to pull the data from the advertiser and display them on their own sites, and appending affiliate tracking links to the product pages provided in the feed.

For example, if an affiliate has several websites that review clothing and decides to promote different clothes from Nordstrom, instead of loading an offer for each individual piece of clothing, Nordstrom would create one offer with an affiliate data feed in XML format. This way the affiliate doesn’t have to hunt through thousands offers, instead, they pull the XML feed and use their own code to show the right products to the right users. The links for the products in the XML feed would include the affiliate’s tracking code so the affiliate would get credit for any sales generated and paid accordingly.

Setting up an XML feed for affiliates saves the advertiser a massive amount of time by linking to all the included products in their store and containing all the products in one offer instead of potentially thousands of different offers.

XML feeds come in a simple URL that contains all the XML data, similar to the one below:

http://myadvertiserstore.com/product-feed

When you visit this URL, you can view the feed XML in your browser. Here is an example of what the feed data can look like:

<?xml version="1.0"?>
<Products>
  <Product>
    <Name>Soft Duvet Set</Name>
    <Description>Seriously soft, gets softer with each wash. Made of 100% cotton. Signature 2" flange.</Description>
    <Price>$139.00</Price>
    <URL>http://thebeddingstore.com/product/392487-Soft-Duvet-Set</URL>
  </Product>
  <Product>
    <Name>Stripe Sheet Set</Name>
    <Description>The single pick construction and washing process produces a fabric that gets softer with each wash. Features embroidered stripes</Description>
    <Price>$95.00</Price>
    <URL>http://thebeddingstore.com/product/987234-Stripe-Sheet-Set</URL>
  </Product>
  <Product>
    <Name>Linen Decorative Pillow</Name>
    <Description>100% linen square pillow. Polyester fill insert included.</Description>
    <Price>$35.00</Price>
    <URL>http://thebeddingstore.com/product/725284-Linen-Decorative-Pillow</URL>
  </Product>
</Products>

Adding a XML Feed Creative

Before you start adding the XML feed into your HasOffers account, you need to enable Deep Links in the offer. This will allow the tracking link to append a custom URL in which it sends the traffic to. Because each product has a different URL, this feature MUST be enabled for the XML feed to work.

Once you have enabled deep links for the offer, go to Offers > Creative Files and click Add Creative. Select the offer(s) that you want to add this feed to, and give the XML feed a name. Make sure to select the “XML Feed” option from the creative types. You can also opt to make the feed private so affiliates can’t grab the URL in their own interface.

The objective of the XML feed is to find the product URLs in the XML file and swap them out for your networks affiliate tracking links that redirect to the product page. To accomplish this the feed parses through the XML tags and looks for a place where the URL tag holds the product page URL. By default, the parser looks for an XML file that is structured like Products > Product > URL.

It looks in the root tag named “Products”, where all the products are nested inside. Then it looks for the next child tag: “Product”, which contains all the tags that attribute for a specific product. Inside this tag should be a “URL” tag that contains the URL of the product. This value is swapped out with an affiliate tracking link, appending the original URL at the end.

If your XML feed is structured like this, you can generate an XML feed URL in the offer page by selecting it from the creative dropdown in the generate tracking section. You will end up with a hosted URL like this:

http://demo.go2feeds.org/feed.php?aff_id=1&offer_id=1&file_id=2034&feed=aHR0cHM6Ly9zaG9wLmxpZ25lLXJvc2V0LmNvLnVrL2ZlZWQv

When you open the URL, the URL tag will have the updated links:

<?xml version="1.0"?>
<Products>
  <Product>
    <Name>Soft Duvet Set</Name>
    <Description>Seriously soft, gets softer with each wash. Made of 100% cotton. Signature 2" flange.</Description>
    <Price>$139.00</Price>
    <URL>http://demo.go2cloud.org/aff_c?aff_id=1&amp;offer_id=1&amp;url=http%3A%2F%2Fthebeddingstore.com%2Fproduct%2F392487-Soft-Duvet-Set</URL>
  </Product>
  <Product>
    <Name>Stripe Sheet Set</Name>
    <Description>The single pick construction and washing process produces a fabric that gets softer with each wash. Features embroidered stripes</Description>
    <Price>$95.00</Price>
    <URL>http://demo.go2cloud.org/aff_c?aff_id=1&amp;offer_id=1&amp;url=http%3A%2F%2Fthebeddingstore.com%2Fproduct%2F987234-Stripe-Sheet-Set</URL>
  </Product>
  <Product>
    <Name>Linen Decorative Pillow</Name>
    <Description>100% linen square pillow. Polyester fill insert included.</Description>
    <Price>$35.00</Price>
    <URL>http://demo.go2cloud.org/aff_c?aff_id=1&amp;offer_id=1&amp;url=http%3A%2F%2Fthebeddingstore.com%2Fproduct%2F725284-Linen-Decorative-Pillow</URL>
  </Product>
</Products>

Parsing Custom XML Feed Tags

With the example above, the HasOffers XML feed tool looks for the Products > Product > URL structure of an XML file to find the product page URL, but many instances this is not how the tag structure is setup by the advertiser. Perhaps the URL tags are named differently or all the tags have different names. In either situation, you can specify what tags to look out for so the tool knows where to look in the XML tag hierarchy. Let’s say for example just the URL tag is named “ProductURL” like you see here:

<?xml version="1.0"?>
<Products>
  <Product>
    <Name>Soft Duvet Set</Name>
    <Description>Seriously soft, gets softer with each wash. Made of 100% cotton. Signature 2" flange.</Description>
    <Price>$139.00</Price>
    <ProductURL>http://thebeddingstore.com/product/392487-Soft-Duvet-Set</URL>
  </Product>
</Products>

In this case we can tell the tool to find that tag by specifying its replacement. When setting up the XML feed creative add the parameter to the end of the original URL:

http://myadvertiserstore.com/product-feed?url_tag=ProductURL

This looks for the “Products” root tag, then the child tag “Product”, and since we specified that the URL tag is actually named “ProductURL”, then the tool knows to replace the URL inside that tag with the affiliate’s tracking link. The “url_tag” parameter is the one that points to the tag with the product page URL.

If the tag structure has more than one different naming for the tags, you just have to use additional parameters to specify which tags match the normal naming convention. For example, let’s look at an XML file that has a similar structure to the standard but differently named tags:

<?xml version="1.0"?>
<Store>
  <Item>
    <Name>Soft Duvet Set</Name>
    <Description>Seriously soft, gets softer with each wash. Made of 100% cotton. Signature 2" flange.</Description>
    <Price>$139.00</Price>
   <ItemURL>http://thebeddingstore.com/product/392487-Soft-Duvet-Set</URL>
  </Item>
</Store>

In the example above, the URL is hosted in a tag called “ItemURL”, which is nested in “Item” and “Store” as the root tag. The tool does not recognize this structure because it doesn’t follow the standard Products > Product > URL naming convention. We have to start at the top level and drill down to the tag containing the URL. Here is how that would look:

http://myadvertiserstore.com/product-feed?objects=Store&object=Item&url_tag=ItemURL

With the parameters added, we are telling the tool that the “Products” parent tag is now named “Store”, and inside that is the “Product” tag, now named “Item”. Inside the Item tag is the URL tag named “ItemURL” and that will have the product page URL.

Adding an Additional Root Tag

There are instances the root tag goes one level higher than an equivalent “Products” tag, like in this example:

<?xml version="1.0"?>
<Store>
  <Products>
    <Product>
      <Name>Soft Duvet Set</Name>
      <Description>Seriously soft, gets softer with each wash. Made of 100% cotton. Signature 2" flange.</Description>
      <Price>$139.00</Price>
      <URL>http://thebeddingstore.com/product/392487-Soft-Duvet-Set</URL>
    </Product>
  </Products>
</Store>

Here, the “Store” tag is the root tag in the file, where the tool is looking for the “Products” tag. However, the “Products” tag is actually nested inside the “Store” tag. In this case, append the “parent” parameter in the original URL:

http://myadvertiserstore.com/product-feed?parent=Store

This tells the tool to start one level up at the “Store” tag and drill down from there.

Now if you have a higher level tag and custom naming for all tags in the file, you can append them as well:

http://myadvertiserstore.com/product-feed?parent=Store&objects=Items&object=Item&url_tag=ItemURL

Passing Parameters Into the Product URL

For offers that use postback tracking or want to pass through certain parameters into the product page URLs, you can do so by appending those values onto the original feed URL when you save it as a Creative File. To do this, encode the query string you want to append to the landing page urls by using a URL encode tool such as the one located at meyerweb.com/eric/tools/dencoder/. Then place it inside the “url_query” parameter of the original feed url.

Example: We want to add to parameters, “sub_id”, “click_id”, and “utm_source”:

sub_id={aff_sub}&click_id={transaction_id}&utm_source=hasoffers

We run that through the encoding tool, and get:

sub_id%3D%7Baff_sub%7D%26click_id%3D%7Btransaction_id%7D%26utm_source%3Dhasoffers

We make this the value of a “url_query” parameter:

&url_query=sub_id%3D%7Baff_sub%7D%26click_id%3D%7Btransaction_id%7D%26utm_source%3Dhasoffers

Finally, we add that parameter to the feed URL provided by our advertiser:

http://myadvertiserstore.com/product-feed?i=dfsdfsdte44c7607d5ca928b&url_query=sub_id%3D%7Baff_sub%7D%26click_id%3D%7Btransaction_id%7D%26utm_source%3Dhasoffers

When these are added to the original feed URL in the Creative File, the ad server passes them through to each URL in the XML feed. All optional macros available in a default offer URL can be passed through to the product URL.

Example PHP Code for Affiliate

Once you have the affiliate data feed attached to an offer, affiliates can start consuming it. Here is a simple PHP example. It uses displays all the records where page is 1 and uses memcache to save the result temporarily for increased performance.

$memcache_obj = new Memcache;
$memcache_obj->connect('127.0.0.1', 11211);
 
$url = "http://demo.go2feeds.org/feed.php?aff_id=1&amp;offer_id=5&amp;file_id=1035&amp;feed=aHR0cDovL2ZlZWRzLm9tZ2V1LmNvbS9kYXRhL2ZlZWQuYXNweA&amp;hash=6dd9f2a3f0854495ba1a2d25c1dd858b&amp;page=1";

$xmlFile = $memcache_obj->get($cache_key);
if ($xmlFile === false || $debug ) {
  $xmlFile = file_get_contents($url);
  if(!empty($xmlFile)) 
   $memcache_obj->set($cache_key, $xmlFile, MEMCACHE_COMPRESSED, 3600*1); 
  }
 
$xml = new SimpleXMLElement($xmlFile);
 
foreach($xml->Products->Product as $product) {
  echo "<div>";
  echo "<h3><a href="".$product->URL."">".$product->Name."</a></h3>";
  echo "<p><img src="".$product->SmallImage."" align="left"/> ".$product->Description."</p>";
  echo "<p>".$product->Price."</p>";
  echo "</div>";
}

No Comments

Leave a reply