Overview

The local_business model should be used when defining sites associated with a business having one or more locations that are open to the public. Such a business will also generally have one or more Google My Business listings and the information entered into the local_business model will be similar to what is shown in these listings. The local_business model serves two main purposes:

  1. It allows json script to be generated according to the localBusiness schema defined at schema.org so that this script can be embedded in your website in accordance with Google's recommendations.
  2. It provides a central place where names, phone numbers and addresses can be defined so that this can be managed and updated in one place, regardless of where the information is embedded within the pages of the site.

Before configuring your local business, you should first set up weekly hours of operations schedules for each business, since these schedules are referenced by the local_business model.

Defining the Local Business Values

Main Fields

The first set of values reflects content that relates to the business as a whole (as opposed to the individual locations). If there is a master email and phone number these would be entered here.

Notice that our featured business (to the right) is a Carpet Cleaning business. Such a business type is not defined by schema.org so we need to assign the business type to the closest match. In this case we have selected Home and Construction Business - General. Schema.org allows for an additionalType which coincides with the last portion of the Wikipedia url (after wiki/) that better describes the type of business or service. In this case, the Wikipedia page is https://en.wikipedia.org/wiki/Carpet_cleaning so we have entered Carpet_cleaning as the Wikipedia Subtype value.

If you want to include the hours of operation use the weekly_schedule model to define these. If these are standard weekday hours such as 9 AM - 5 PM you can include one of the weekly schedules defined in system. If the hours differ by location, you can enter the most common hours as the default schedule and override this at the location level for locations whose hours differ.

Department Contact Information

If entered, this will be used to generate contactPoints. If your business has separate public phone numbers or email addresses for different departments you can enter these here.

Local Addresses

There should be one row in this section for each Google My Business listing associated with the company. If there are separate local phone numbers and email addresses for each location enter these here. Otherwise, leave these blank and they will default to the ones specified in the main fields.

In order to obtain the lat/long of the address you can search for the address in Google Maps and the resulting url should contain the lat/long.

Social Media Links

Define all of the external site pages that are associated with this business. This is used to generate the sameAs tags in the schema and also can be used to generate social media links.

Payment Types

Add any necessary rows to select all of the payment types that apply.

Stowing the local_business Specification

When stowing this specification, you should leave the name empty and it will default to mybusiness.

Adding Local Business Data to Your Website

Generally speaking you should have a dedicated page on your website for each business location. This page will generate the json script to describe that location. For businesses with multiple locations, you may have a page on the website that shows all locations. In this case, you can define an organizational schema that would show all location addresses.

Creating an Address Template

An address template is similar to other page sections except that it contains placeholders instead of actual address values. For basic address content, you can use the following template from system called local_business/simple-name-addr-phone.

Simple local address template

Notice that templates may include $function references however, such references must use the word DOLLAR (in upper case) rather than the $ symbol. The following placeholders can be used within the template.

These will be taken from the main business values:

  • :business_name:
  • :main_telephone:
  • :main_fax:
  • :main_email:

These placeholders will be substituted for values taken from a specific location:

  • :identifier:
  • :division:
  • :link_to_page:
  • :street:
  • :city:
  • :region:
  • :postal_code:
  • :country:
  • :po_box:
  • :po_box_formatted: (If po_box is set, this will be formatted as P. O. Box xxx<br />)
  • :local_telephone: (if empty, main telephone will be returned)
  • :local_email: (if empty, main email will be returned)
  • :local_email_link_text:
  • :image:
  • :map_link:
  • :area_served:
  • :aggregate_rating:

:css_class: can also be referenced in the template and can be substituted for a class value.

To render the template with the local_business values substituted we use the $local_business function. Here is an example of how this is called:

$local_business(chatham,local_business/simple-name-addr-phone,subtle,hc)

Let's review the parameters passed to this function.

  1. The first parameter must match a value in column 1 of the Local Addresses section. This determines which local address values will be returned.
  2. The second parameter is the name of the template page that you want to use. This template can be created by any page oriented model such as tags, table, bootgrid, markdown, etc. In the example function we have used a page that is supplied in system called local_business/simple-name-addr-phone.
  3. The third parameter is used to supply a class name for substituting any :css-class: references within the template.
  4. The final parameter (if supplied) will trigger the generation of json script. This consists of a series of flags which are described below.

json Script Flags

As per Google's recommendations, you should not generate json schema definitions for content that does not appear on the page. For example, you may have defined a weekly hours schedule for your local business. However, if the page for which you are generating a schema does not show these hours, Google states that you should not incorporate the hours into the json schema for the page. Therefore, the purpose of these flags is to control which portions of the schema get generated so that you can align the json schema with the visual content of the page. Here is a summary of the flags that are available:

c

Controls the generation of contactPoints into the schema.

p

Controls the generation of the paymentAccepted definition.

a

Controls the generation of areaServed definition.

h

Controls the generation of schedule of openingHours.

*

Asterisk is a special flag that is used to indicate that you would like all locations to be generated into the schema. Recall that we recommend having a separate page for each location and only generating json for the current location. Nevertheless, it is possible to define a page that shows all locations together. For such a page, you can use * in the flag column (as well as the other desired flags) to request that json schema be generated for all locations. This will set up a separate Organization structure and place the locations under the location. The division names specified for each location will be added to the end of the main business name.

If none of the above flags apply, set the flag value to "1" (the number one) to trigger the generation of the basic address information for one location.

Examples

Consider the following location definitions:

Sample local_business location definitions

Notice there are two locations.

Rendering One Location On the Page

If we want to build a page that shows the chatham location and also generates a json schema for this location which includes the hours and the area served we can code the following dollar function:

$local_business(chatham,local_business/simple-name-addr-phone,mycss,ha)

This will generate the following content onto the page:

Hugh's Carpet & Upholstery Cleaning
25 Sass Road
Chatham-Kent Ontario
N7M 5K3
Phone: (519) 354‑1234

This function will also add the following json schema to the page:

<script type="application/ld+json">
{"@context": "http://schema.org",
"@type": "HomeAndConstructionBusiness",
"additionalType": "http://www.productontology.org/id/Carpet_cleaning",
"name": "Hugh's Carpet & Upholstery Cleaning",
"legalName": "Hugh's Carpet Cleaning Inc.",
"url": "http://localhost/hughscarpet/",
"description": "Carpet, tile and upholstery cleaning service.",
"logo": "http://localhost/hughscarpet/images/logo-xs.png",
"sameAs": "https://www.facebook.com/hughsfloorandupholstery/",
"faxNumber": "(519) 354-7388",
"priceRange": "$$",
"address": {
"@type": "PostalAddress",
"streetAddress": "25 Sass Road",
"addressLocality": "Chatham-Kent",
"addressRegion": "Ontario",
"postalCode": "N7M 5K3",
"postOfficeBoxNumber": "154",
"addressCountry": "Canada"
},
"image": "http://localhost/hughscarpet/images/hughs-carpet-cleaning-xs.png",
"email": "sales@hughscarpetcleaning.com",
"telePhone": "(519) 354‑1234",
"areaServed": "Chatham-Kent","Blenheim","Bothwell","Dresden","Erieau","Florence","Kent Bridge","Merlin",
 "Mitchell's Bay","Pain Court","Port Lambton","Ridgetown","Thamesville","Tupperville","Wallaceburg",
"hasMap": "https://www.google.ca/maps/place/Hughs+Floor+%26+Upholstery+Cleaning/@42.4136272,-82.1689127,
  14.75z/data=!4m12!1m6!3m5!1s0x0:0x7787ef1e86ba3b49!2sHughs+Floor+%26+Upholstery+Cleaning!8m2!3d42.
    4126081!4d-82.1652019!3m4!1s0x0:0x7787ef1e86ba3b49!8m2!3d42.4126081!4d-82.1652019",
"openingHours": "Mo-Fr 08:30-16:30",
"geo": {
"@type": "GeoCoordinates",
"latitude": "42.4126081",
"longitude": "-82.1652019"
}
}
</script>

Rendering Multiple Locations

Let's assume that the page you are creating needs to show all locations and you want to reflect this in the json schema. You would need to define a separate $local_business function for each location as shown here:

$local_business(chatham,local_business/simple-name-addr-phone,subtle,c*)
$local_business(windsor,local_business/simple-name-addr-phone,subtle)

Please make note of the following:

  1. We have included a c in the flags to trigger the showing of Contact Points
  2. We have included the * flag to indicate that all locations are to be generated into the schema
  3. When using this method, only one of the $local_business functions should include parameter 4.

Here we can see that both addresses have been generated using the same template:

Hugh's Carpet & Upholstery Cleaning
25 Sass Road
Chatham-Kent Ontario
N7M 5K3
Phone: (519) 354‑1234

Hugh's Carpet & Upholstery Cleaning
33 Riverside Dr E.
Windsor Ontario
N9A 2S4
Phone: (519) 224 1232

And the following schema has also been generated:

<script type="application/ld+json">
{"@context": "http://schema.org",
"@type": "Organization",
"name": "Hugh's Carpet & Upholstery Cleaning",
"legalName": "Hugh's Carpet Cleaning Inc.",
"url": "http://localhost/hughscarpet/",
"description": "Carpet, tile and upholstery cleaning service.",
"logo": "http://localhost/hughscarpet/images/logo-xs.png",
"sameAs": "https://www.facebook.com/hughsfloorandupholstery/",
"contactPoint": {
"@type": "ContactPoint",
"contactType": "Commercial Sales",
"telephone": "+5193541234",
"email": "sales@hughscarpetcleaning.com"
},
{
"@type": "ContactPoint",
"contactType": "Residential Appointments",
"telephone": "+5193514321",
"email": "service@hughscarpetcleaning.com"
},
"faxNumber": "(519) 354-7388",
"priceRange": "$$",
"Location":
{
"@type": "HomeAndConstructionBusiness",
"additionalType": "http://www.productontology.org/id/Carpet_cleaning",
"parentOrganization": {"name": "Hugh's Carpet & Upholstery Cleaning"},
"name": "Hugh's Carpet & Upholstery Cleaning - Head Office",
"address": {
"@type": "PostalAddress",
"streetAddress": "25 Sass Road",
"addressLocality": "Chatham-Kent",
"addressRegion": "Ontario",
"postalCode": "N7M 5K3",
"postOfficeBoxNumber": "154",
"addressCountry": "Canada"
},
"image": "http://localhost/hughscarpet/images/hughs-carpet-cleaning-xs.png",
"hasMap": "https://www.google.ca/maps/place/Hughs+Floor+%26+Upholstery+Cleaning/@42.4136272,-82.1689127,
  14.75z/data=!4m12!1m6!3m5!1s0x0:0x7787ef1e86ba3b49!2sHughs+Floor+%26+Upholstery+Cleaning!8m2!3d42.
    4126081!4d-82.1652019!3m4!1s0x0:0x7787ef1e86ba3b49!8m2!3d42.4126081!4d-82.1652019",
"geo": {
"@type": "GeoCoordinates",
"latitude": "42.4126081",
"longitude": "-82.1652019"
}
,{
"@type": "HomeAndConstructionBusiness",
"additionalType": "http://www.productontology.org/id/Carpet_cleaning",
"parentOrganization": {"name": "Hugh's Carpet & Upholstery Cleaning"},
"name": "Hugh's Carpet & Upholstery Cleaning - Service",
"address": {
"@type": "PostalAddress",
"streetAddress": "33 Riverside Dr E.",
"addressLocality": "Windsor",
"addressRegion": "Ontario",
"postalCode": "N9A 2S4",
"addressCountry": "Canada"
},
"telePhone": "(519) 224 1232",
"hasMap": "https://www.google.ca/maps/place/Hughs+Floor+%26+Upholstery+Cleaning/@42.3194837,
  -83.0394413,15z/data=!4m7!3m6!1s0x0:0xa1a50b76dc4b5f79
!5m1!1s2018-04-29!8m2!3d42.3194837!4d-83.0394413",
"geo": {
"@type": "GeoCoordinates",
"latitude": "42.3194837",
"longitude": "-83.0394413"
}

}
</script>

Accessing Individual Local Data Fields

Individual elements of the local_business definition can be accessed using the $object function. For scalar fields the format of this function is:

$object(mybusiness,field-name)

For example: $object(mybusiness,business_name)

Other scalar fields include

  • legal_name
  • business_description
  • main_telephone
  • main_fax
  • main_email
  • logo (the image id of the logo)
  • default_schedule

It is also possible to access address fields by passing parameters in the following pattern:

$object(mybusiness,location,locationid,field-name)

For example $object(mybusiness,location,windsor,street)

Using this pattern the following field-names are supported:

  • division
  • link_to_page
  • street
  • city
  • region (this is generally a state or province)
  • postal_code
  • country
  • po_box
  • po_box_formatted (If po_box is set, this will be formatted as P. O. Box xxx<br />)
  • local_telephone
  • local_email
  • local_email_link_text
  • image
  • map_link
  • area_served
  • aggregate_rating

You can also use this method to return the combined address formatted on several lines using the function:

$object(mybusiness,location,windsor,address)

By default, the P.O. Box (if entered) is not included in the formatted address. Nevertheless, this can be requested by passing a fourth parameter. Pass 1 to show the P.O. Box on row 1 of the address, pass 2 to show the P.O. Box on row 2 (after the street). For example, this will add the P.O. Box on line 2 (only if there is a P.O. Box entered for the address)

$object(mybusiness,location,chatham,address,2)

Joining Several Local Business Fields

A final method of retrieving local business values is to use this format:

$object(mybusiness,join,locationid,value1,value2,value3,...)

In this case, the values can either be field references or constants. For example:

$object(mybusiness,join,windsor,<b>,business_name,</b><br />,street,<br />,city, ,region,<br />,postal_code,<br /><br />Phone: ,local_telephone)

Will render the following html:

<b>Hugh's Carpet & Upholstery Cleaning</b><br />33 Riverside Dr E.
<br />Windsor Ontario<br />N9A 2S4<br /><br />Phone: (519) 224 1232

Which will appear as this:

Hugh's Carpet & Upholstery Cleaning
33 Riverside Dr E.
Windsor Ontario
N9A 2S4

Phone: (519) 224 1232

Part of a specification for a local business
🡇
Example of a rendered business