Cookbook/Classifieds

GoodRelations for Classified Ads

The special challenge when exposing structured data for classified ads are the following:

  1. You typically just have a headline, a body text, and incomplete contact information.
  2. The exact identity of the offering party is unknown and often limited to a screen-name or just the phone number.

In GoodRelations, simply put the headline in gr:name, the body text in gr:description and try to parse the phone number and the price so that you can populate the elements in the following example.

<div xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     ns="http://www.w3.org/1999/xhtml"
     xmlns:foaf="http://xmlns.com/foaf/0.1/"
     xmlns:gr="http://purl.org/goodrelations/v1#"
     xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
     xml:lang="en" >
<!-- The Classified Ad content -->
  <div about="#offering" typeof="gr:Offering">
    <div rev="gr:offers" resource="#user1234"></div>
    <strong property="gr:name" >Classified ad - headline (e.g. the text in bold)</strong>
    <div property="gr:description">Here comes the full text of the classified ad .... blablabla</div>
<!-- if you have an image, use this pattern -->
    <img rel="foaf:depiction" src="http://www.heppnetz.de/rdfa4google/image.jpg" />
<!-- if you know the type of business function (Sell, LeaseOut, Dispose, ProvideService,
       attach it like this -->
    <div rel="gr:hasBusinessFunction" resource="http://purl.org/goodrelations/v1#Sell"></div>
<!-- if you can provide the price in a structured form, use this pattern (needed for Rich Snippets) -->
    <div rel="gr:hasPriceSpecification">
      <div typeof="gr:UnitPriceSpecification">
        <div property="gr:hasCurrency" content="USD" datatype="xsd:string"></div>
        <div property="gr:hasCurrencyValue" content="89" datatype="xsd:float"></div>
      </div>
    </div>
<!-- provide the URI of a deep link to the page -->
    <div rel="foaf:page" resource="http://www.heppnetz.de/rdfa4google/tc16.html"></div>
  </div>

<!-- The contact information of the seller - omit fields that you do not have -->
  <div about="#user1234" typeof="gr:BusinessEntity">
    Call <span property="gr:name">Peter Miller</span> at
    <div property="vcard:tel" content="+1 408 970-6104"></div>
  </div>
</div>

</body>
</html>

This validates in the Google Rich Snippet Testing Tool, as you can see:

The list of all supported business functions is here: