Product Schema Markup for Ecommerce: A JSON-LD Example and Merchant Listings
In this article
Product schema markup is a block of JSON-LD on a product page. It tells Google, in a fixed vocabulary, what the product is, what it costs, whether it is in stock and how it ships. With it, a product page becomes eligible for two kinds of enhanced search result. Product snippets add price, availability and ratings under the blue link. Merchant listings can show the image, shipping cost and returns window in Search and in the Shopping tab.
Eligible is the right word. Correct markup is the entry condition, not a guarantee; Google decides whether to show the enhancement and checks that the markup matches the page. Below is a complete example, what each field is for, and what merchant listing eligibility really requires. It also covers how we generate the markup from the database in Django so it cannot disagree with the page.
What product structured data gets you
Google's product structured data documentation describes two result types with different requirements, and confusing them is where most Search Console errors come from.
| Result type | Shown where | Page it applies to | Minimum markup | What it can add |
|---|---|---|---|---|
| Product snippet | Standard web results | Any page about one product, including reviews | Product name plus at least one of offers, review or aggregateRating | Price, availability, star rating |
| Merchant listing | Web results, the Shopping tab, image results | Only a page where the shopper can buy that product | Product name, image, and an Offer with price and currency | Image, shipping cost and time, returns window, stock, sale price |
A category or brand page can qualify for nothing beyond a snippet, however good the markup; a merchant listing is only for the page with the add-to-basket button.
A correct Product example in JSON-LD
This is the block as it sits in a product page, with the values a UK shop would use. Every property is required or recommended by Google for a merchant listing.
<script type="application/ld+json">
{
"@context": "https://schema.org/",
"@type": "Product",
"name": "Walnut Serving Board, 40 cm",
"image": [
"https://example.com/media/boards/walnut-40-front.jpg",
"https://example.com/media/boards/walnut-40-side.jpg"
],
"description": "A hand-finished walnut serving board, 40 cm by 22 cm, oiled and ready to use.",
"sku": "WSB-40",
"gtin13": "5012345678900",
"brand": {
"@type": "Brand",
"name": "Example Woodworks"
},
"offers": {
"@type": "Offer",
"url": "https://example.com/products/walnut-serving-board-40cm/",
"price": 42.00,
"priceCurrency": "GBP",
"availability": "https://schema.org/InStock",
"itemCondition": "https://schema.org/NewCondition"
}
}
</script>
- name, description, image. The same values the shopper sees. Give two or more images at different crops; Google may use them in the listing.
- sku and gtin13. Your own code and the barcode. A GTIN lets Google match the product to its catalogue. Leave
gtin13out if the product has no barcode; never invent one. - brand. A
Brandobject, not a plain string, even when the brand is your own shop. - offers.url. The canonical URL of this product page, which must be the page the markup is on.
- price and priceCurrency. The VAT-inclusive price a UK consumer pays, as a number with a decimal point, and the ISO currency code. The price in the markup must equal the price on the page.
- availability. One of the schema.org values as a full URL:
InStock,OutOfStock,PreOrder,BackOrderorLimitedAvailability. Updated from live stock, never hard-coded.
Shipping and returns in the offer
Shipping cost and returns policy are what turn a basic listing into a useful one, and both can be declared inside the offer. For a shop that posts within the UK with free returns within 14 days:
"shippingDetails": {
"@type": "OfferShippingDetails",
"shippingRate": {
"@type": "MonetaryAmount",
"value": 3.95,
"currency": "GBP"
},
"shippingDestination": {
"@type": "DefinedRegion",
"addressCountry": "GB"
},
"deliveryTime": {
"@type": "ShippingDeliveryTime",
"handlingTime": {"@type": "QuantitativeValue", "minValue": 1, "maxValue": 2, "unitCode": "DAY"},
"transitTime": {"@type": "QuantitativeValue", "minValue": 1, "maxValue": 3, "unitCode": "DAY"}
}
},
"hasMerchantReturnPolicy": {
"@type": "MerchantReturnPolicy",
"applicableCountry": "GB",
"returnPolicyCategory": "https://schema.org/MerchantReturnFiniteReturnWindow",
"merchantReturnDays": 14,
"returnMethod": "https://schema.org/ReturnByMail",
"returnFees": "https://schema.org/FreeReturn"
}
Both can also be declared once for the whole site, through Merchant Center or Organization markup, which is simpler when every product ships on the same terms. Whatever you declare must be what you do: 14 days is the legal minimum for distance sales in the UK, and a shop that offers 30 should say 30.
Merchant listing eligibility, honestly
The markup makes a page eligible. These are the conditions that decide whether it stays eligible, in the order we see them fail.
- The markup must match the visible page. If the page shows £42 and the markup says 39.99 because a sale ended and only one of them was updated, the listing is dropped. Generate both from the same database field.
- One product, one page, purchasable there. The page needs the price, the availability and a way to buy. Markup for a product that is only sold elsewhere, or a page listing several products, does not qualify.
- Out of stock is fine; wrong stock is not. Keep the page and set
OutOfStock. Google may still show it. What loses trust is a page that says in stock while the markup, or the basket, says otherwise. - Reviews must be real and on the page. An
aggregateRatingis allowed only when the reviews it summarises are visible on that page and came from customers. No reviews means no rating property, not a made-up one. - Merchant Center is separate, and worth having. On-page markup can qualify a page for merchant listings in Search on its own. A Merchant Center feed is what gives you the Shopping tab reliably, the reasons for a disapproval, and sitewide shipping and returns settings. With both, the feed and the markup must agree.
Search Console has a Merchant listings report and a Product snippets report. They show which pages are eligible and which have errors, and that is where to look before assuming the markup is not working.
Variants, sale prices and the currency a crawler sees
Three situations catch most shops out. A product in several sizes or colours should use Google's variant markup. That is a ProductGroup with hasVariant entries for each variant and variesBy stating which properties differ, so that search can show the right size with the right price. The post on fashion ecommerce websites and variant handling covers the data model that makes this easy to generate.
A sale price goes in price, with the previous price declared as a priceSpecification of type UnitPriceSpecification and priceType set to https://schema.org/ListPrice. That is how a crossed-out price can appear. Add priceValidUntil so the sale price is not shown after it ends.
Currency needs care on any shop that shows prices in more than one. Googlebot crawls mainly from the United States. So a site that switches currency by the visitor's location will be crawled in dollars while the markup, if it is hard-coded, says GBP. Stamp and Bake shows prices in 22 currencies. A shop like that has to render the markup from the same price and currency as the page it is serving to that visitor. It also has to make sterling the default when no choice has been made.
Generating it from Django so it never disagrees with the page
We never write JSON-LD by hand. The view builds a dictionary from the same product object that renders the visible price, stock and images, and the template prints it, so the two cannot drift.
def product_ld(product, request):
offer = {
"@type": "Offer",
"url": request.build_absolute_uri(product.get_absolute_url()),
"price": str(product.price_inc_vat),
"priceCurrency": "GBP",
"availability": product.schema_availability(),
"itemCondition": "https://schema.org/NewCondition",
}
data = {
"@context": "https://schema.org/",
"@type": "Product",
"name": product.name,
"image": [request.build_absolute_uri(i.url) for i in product.images.all()],
"description": product.short_description,
"sku": product.sku,
"brand": {"@type": "Brand", "name": product.brand.name},
"offers": offer,
}
if product.gtin:
data["gtin13"] = product.gtin
return json.dumps(data, ensure_ascii=False).replace("</", "<\\/")
The last line matters: a description containing a closing tag would otherwise end the script block early. The block is printed server-side in the template, in the HTML Google first receives. That is one of the reasons the comparison of server-side and client-side rendering for SEO comes down on the server side for shops. Markup injected by JavaScript after load is usually read eventually, but later and less reliably. The same approach extends to every product in an electronics shop with structured specification data, where the GTIN and brand come from the catalogue fields.
Testing and keeping it right
- Paste a product URL into Google's Rich Results Test. It reports which result types the page is eligible for and lists every missing or invalid property.
- Use the Schema Markup Validator at schema.org for the vocabulary itself.
- Check Search Console's Merchant listings and Product snippets reports monthly. A new error after a deploy usually means a template change broke a field.
- Add structured data to the launch checks for the shop. Our technical SEO audit checklist includes a script that fetches every product URL and validates the JSON-LD, which is faster than clicking through the test one page at a time.
Structured data is one of the technical SEO jobs we fix in the code as part of SEO work on the sites we build. It sits alongside the on-page work the guide to on-page, technical and content SEO describes.
Questions people ask
Does product schema improve rankings?
Not directly. It changes how the result looks, which changes how often it is clicked. A result with a price and "in stock" draws the shoppers who were going to buy, and the ones who would have bounced on the price stay away.
Do I need Google Merchant Center as well as schema markup?
Not for product snippets, and not strictly for merchant listings in Search, but a Merchant Center feed is the dependable route into the Shopping tab and gives you error reports. Most shops should have both and keep them in agreement.
Should out-of-stock products keep their schema?
Yes, with availability set to out of stock. The page keeps its ranking and Google may still show it. Remove the markup only if the product is discontinued, and then redirect the page to its closest replacement.
Can I add a star rating if I do not have reviews?
No. An aggregate rating must summarise real customer reviews shown on the page. Markup with invented ratings is the fastest way to lose every enhancement on the site.
Where to start
Run the Rich Results Test on your best-selling product page and read the list of what is missing. Then fix it in the template, not the page, so that every product gets the fix at once. Name, image, description, sku, brand and an offer with price, currency and availability is the whole first job; shipping, returns and variants are the second.
Once the markup is right, leave it alone and check the Search Console reports after each deploy. The guide to product pages that convert covers what to do with the visitors the better listing brings.