ajax

Using AJAX and PHP to Create Page Content Linked to Keywords in URL

This article is designed to give an overview of the processes involved in creating context sensitive content that is designed to generate revenue. It is important because no content-oriented site can exist just be serving up information; they have a need to sell something to support this activity.

The trick is to:

  • Create themed content
  • Isolate key phrases that buyers use to find products
  • Give the buyers information
  • Sell them what they want to buy

This last is where the context sensitive content model comes into play, as products can be selected from any online vendor that supports XML or HTML query-response mechanisms (such as REST). If the correct keywords are supplied, then the result will be a selection of products that the visitor will want to buy.

The content leads to higher page views, and the dynamic content leads to higher conversion rates.

Context Sensitive Content

The dynamic content being served can be linked to one of two mechanisms:

  • linked to keywords within the content (AdSense model)
  • linked to tags and queries in the URL (ad-hoc model)

The first is the Google AdSense model, which populates advert panels with adverts reflecting the keywords found in the text. The second uses a technique that relies on the organizational model of the underlying content management system, although some ad-hoc implementations might also use the HTML head section meta tag containing the description or keywords.

If the dynamic content is linked to keywords on page (or in meta tags) and if those keywords are buyers keywords, then income can be generated through PPC adverts or affiliate sales.

Placeholders & Integration with CMS

On the page itself HTML div elements are used to to create special areas of HTML. These can then be accessed by name, and their properties set (show/hide, for example) using JavaScript.

The innerHTML property is also set dynamically to reflect the contents of the data source used to populate the dynamic content (affiliate sales links, adverts etc.). This HTML can be generated on the front-end (using JavaScript ; AJAX) or the backend (using PHP).

It is then just a case of pulling tags from the URL using JavaScript string.split (as described in the Dynamic Redirect with JavaScript article) or keywords from the source, and creating a query to retrieve up to date content from a server or another web site. For example, if serving pay per click adverts, like Google AdSense does, PHP could be used on the backend to read adverts from a database.

Data Sources

Other data sources for affiliate products and services include:

  • Amazon via REST interface
  • XML & RSS Feeds from providers such as YouTube, eBay, etc.
  • Mashup providers such as Yahoo! Pipes & Feed43.com
  • Specialized API such as Google’s GDATA

All of the above provide at least a basic API which can be used as a straightforward HTTP call, which might look something like the following:

www.server.com/list_products.php?keywords=key+words&affiliate=aff_id

The result is commonly an XML tree that can be processed via PHP or JavaScript (the AJAX approach).

Using PHP

If PHP is used on the backend then the incoming XML can also be processed using PHPs SimpleXML (as described in the PHP SimpleXML Blogger Syndication article). The advantage of this approach is that the feeds can be filtered to match the exact keywords being targeted, or several feeds merged together in a Yahoo! Pipes style mashup.

As long as the result is correctly generated HTML, then it can be displayed using the AJAX mechanism discussed in the Placeholders section of this article.

Leave a Reply

Your email address will not be published.