Enrich search results

Highlighted
Tourist
25 0 2

Hi,

 

i want to enrich search results, with, product informations when a product appear on google.

 

Something like price, stock and images. I know i must use JSON and pu int in my store code, but i d'ont even know how to proceed.

 

I want to do it on pages too, like images near my homepage when it appear on google.

 

Someone can help me ?

 

Thank you for reading

0 Likes
Highlighted
Shopify Partner
248 9 58

Try putting something like this at the bottom of your product.liquid template file.

 

 

{%- assign cats = '' -%}{%- for c in product.collections -%}{%- assign c2 = c.handle | replace: '-',' ' -%}{%- assign cats = cats | append: '"' | append: c2 | append: '"' -%}{%- if forloop.last != true -%}{%- assign cats = cats | append:',' %}{%- endif -%}{%- endfor -%}
<script type="application/ld+json">
{
  "@context": "http://schema.org/",
  "@type": "Product",
  "url": "{{ shop.url | append: '/products/' | append: product.handle }}",
  "name": "{{ product.title | strip_html | escape }}",
  "image": "https:{{ product.featured_image.src | img_url: 'master' }}",
  "description": "{{ product.description | strip_html | escape }}",
  {%- if cats != blank -%}
  "category": [
    {{ cats }}
  ],
  {%- endif -%}
  "brand": {
    "name": "{{ product.vendor }}"
  },
  "offers": {
    "@type": "Offer",
    "priceCurrency": "{{ shop.currency }}",
    "price": "{{ product.selected_or_first_available_variant.price | money | remove: ' ' }}",
    "availability": "http://schema.org/{% if product.available %}InStock{% else %}OutOfStock{% endif %}",
    "seller": {
      "@type": "Organization",
      "name": "{{ shop.name }}"
    }
  }
}
</script>
0 Likes