Menu Close

Get Support From ShopWired Close

All Systems Operational

Subscribe To Updates
Prefer To Live Chat? Chat directly with ShopWired support Quickest response time

Prefer To Phone?

Call us on 0330 111 2024 (free from landlines and mobiles)

Available 9.30am to 5.30pm Monday to Friday


Send A Message
Response within 24 hours

Menu Close

Menu

How to add structured data to the products on your theme

You can add code to your theme's files to provide Google, and other search engines/providers, with detailed information about your products (in a structured format), by following the instructions below.

More information about Structured Data can be found on Google's website here and on the schema.org/Product website here.


Adding the code

You'll need to use the page editor to make changes to the product.twig file for your theme.

Open the product.twig file.

Scroll to the bottom of the file. Right before the {% endblock %} piece of code, add the code shown below.

<script type="application/ld+json">
    {
        "@context": "http://schema.org/",
        "@type": "Product",
        "name": {{ product.title|json_encode|raw }},
        {% if product.photo_url %}
            "image": "{{ product.photo_url }}",
        {% endif %}
        "description": {{ product.description|striptags|json_encode|raw }},
        {% if product.sku %}
            "sku": {{ product.sku|json_encode|raw }},
        {% endif %}
        {% if product.brand %}
            "brand": {{ product.brand.title|json_encode|raw }},
        {% endif %}
        {% if reviews_enabled %}
            {% if product.reviews|length > 0 %}
                "aggregateRating": {
                    "@type": "AggregateRating",
                    "ratingValue": "{{ product.rating }}",
                    "reviewCount": "{{ product.reviews|length }}"
                },
            {% endif %}
        {% endif %}
        "offers": {
            "@type": "Offer",
            "priceCurrency": "{{ global.business.currency }}",
            "price": "{{ product.sale_price > 0 ? product.sale_price : product.price }}",
            "itemCondition": "http://schema.org/NewCondition",
            {% if product.in_stock %}
            "availability": "http://schema.org/InStock",
            {% endif %}
            "seller": {
                "@type": "Organization",
                "name": "{{ global.business.name }}"
            }
        }
    }
</script>

As shown in the example below.

You can use Google's Structured Data Testing Tool to test that the code is working and has been added correctly.