Created on 7 May, 2015 | Updated on 11 December, 2022
Adding Structured Data to Shopify for Google Merchant (JSON-LD)

Adding Structured Data to Shopify for Google Merchant & Facebook (JSON-LD)

If you have received errors or warnings regarding missing or invalid data for prices, condition, availability, etc… Then the code below will solve this issue. You will need to both updates Opengraph and JSON-LD. Copy the JSON-LD code and paste it inside your product.liquid file using the latest JSON-LD technology. And replace two lines in your social-meta-tag file. This code supports variants by keeping the first selected product as the first iteration. If you have multiple variants such as colors and the second color is preselected based on the URL. This is done to follow the Google Merchant Center guidelines and while keeping SEO integrity.

This tutorial no longer supports the old Microdata technology as JSON-LD is a lot faster to read for Google Bots.

This code now also supports id’s for Facebook, so you can import product data using structured data.

Supported Functions

  • Facebook ID value.
  • Auto currency detection
  • Auto decimal separator detection
  • Extra instructions to fix Opengraph pricing issues

Requirements

  • Google Merchant Center > Products > All Products
  • Access to Shopify > Theme > product.liquid or
  • Add it to your theme.liquid file body tag

Important:
It is required you remove all your old structured data coding, to avoid conflicts. If you do not know how to do this, you can ask for my help using the contact form below

From the code example below, edit the value between code settings start and end. Do not change anything else or you might break the functionality. I have highlighted below what you can edit.

FeedArmy Edit Structured Data Config
  1. By default the code is set up for the US, if you targeting a different country, change the value of fa_product_id_alpha2_code to your target country alpha2. For example, the United Kingdom is GB. You can find the full list here: https://help.shopify.com/en/api/custom-storefronts/storefront-api/reference/enum/countrycode
  2. The following step requires you to check the product id in Google Merchant Center > Products > List. And see what ID you are using.
    1. If it looks like shopify_US_81191654332_1055121650148, then keep fa_product_id set to default
    2. If it looks like 1055121650148 then set the value fa_product_id to product_id
    3. If it looks like the main id 81191654332 then set the value fa_product_id to parent_id
    4. If it looks like a sku then set the value fa_product_id to sku

The Code

<!-- Copyright FeedArmy 2022 Version 3.18 -->
<!-- FeedArmy tutorial found at https://feedarmy.com/kb/shopify-microdata-for-google-shopping/ -->

<!-- CODE SETTINGS START -->
<!-- CODE SETTINGS START -->

<!-- Please add your alpha2 code, you can find it here: https://help.shopify.com/en/api/custom-storefronts/storefront-api/reference/enum/countrycode -->
{%- assign fa_product_id_alpha2_code = 'US' -%}

<!-- set your product id values are default, product_id, parent_id, sku-->
{%- assign fa_product_id = 'default' -%}

<!-- CODE SETTINGS END -->
<!-- CODE SETTINGS END -->

<!-- ==================================== -->
<!-- DO NOT EDIT ANYTHING BELOW THIS LINE -->

{%- if template contains 'product' -%}

{%- assign fa_current_variant = product.selected_or_first_available_variant -%}

{%- if fa_product_id == 'default' -%}
{%- capture fa_product_id_value -%}shopify_{{ fa_product_id_alpha2_code }}_{{ product.id }}_{{ fa_current_variant.id }}{%- endcapture -%}
{%- elsif fa_product_id == 'product_id' -%}
{%- capture fa_product_id_value -%}{{ fa_current_variant.id }}{%- endcapture -%}
{%- elsif fa_product_id == 'parent_id' -%}
{%- capture fa_product_id_value -%}{{product.id }}{%- endcapture -%}
{%- elsif fa_product_id == 'sku' -%}
{%- capture fa_product_id_value -%}{{ fa_current_variant.sku | escape }}{%- endcapture -%}
{%- endif -%}

{%- if cart.currency.iso_code == 'GBP' or cart.currency.iso_code == 'USD' or cart.currency.iso_code == 'AUD' or cart.currency.iso_code == 'AED' or cart.currency.iso_code == 'CAD' or cart.currency.iso_code == 'BWP' or cart.currency.iso_code == 'BND' or cart.currency.iso_code == 'DOP' or cart.currency.iso_code == 'GTQ' or cart.currency.iso_code == 'HKD' or cart.currency.iso_code == 'INR' or cart.currency.iso_code == 'ILS' or cart.currency.iso_code == 'YEN' or cart.currency.iso_code == 'KES' or cart.currency.iso_code == 'KOR' or cart.currency.iso_code == 'LBP' or cart.currency.iso_code == 'MYR' or cart.currency.iso_code == 'MXN' or cart.currency.iso_code == 'NPR' or cart.currency.iso_code == 'NZD' or cart.currency.iso_code == 'NIO' or cart.currency.iso_code == 'NGN' or cart.currency.iso_code == 'PKR' or cart.currency.iso_code == 'CNY' or cart.currency.iso_code == 'PHP' or cart.currency.iso_code == 'SGD' or cart.currency.iso_code == 'LKR' or cart.currency.iso_code == 'CHF' or cart.currency.iso_code == 'TWD' or cart.currency.iso_code == 'TSH' or cart.currency.iso_code == 'THB' or cart.currency.iso_code == 'UGX' or cart.currency.iso_code == 'KWD' or cart.currency.iso_code == 'CLP' or cart.currency.iso_code == 'BHD' -%}
{%- assign fa_product_price = fa_current_variant.price | money_without_currency | remove:',' -%}
{%- else -%}
{%- assign fa_product_price = fa_current_variant.price | money_without_currency | remove:'.' | replace: ',', '.' -%}
{%- endif -%}


<script type="application/ld+json" data-creator_name="FeedArmy">
{
  "@context": "http://schema.org/",
  "@type": "Product",
  "@id": {{ canonical_url | json }},
  "name": "{{ product.title | strip_html | escape }}",
  "url": "{{ shop.url }}{{ product.url }}",
  "sku": "{{fa_product_id_value}}",
  {%- if product.variants.first.barcode.size >= 12 and product.variants.first.barcode.size <= 14 -%}
  "gtin": {{ product.variants.first.barcode }},
  {%- endif -%}
  "productID": "{{ product.id }}",
  "brand": {
    "@type": "Brand",
    "name": "{{ product.vendor | escape }}"
  },
  "description": {{ product.description | strip_html | json }},
  "image": "https:{{ product.featured_image.src | img_url: '1500x1500' }}",
  {%- if product.variants -%}
    "offers":
      {
        "@type" : "Offer",
        "priceCurrency": "{{ cart.currency.iso_code }}",
        "price": "{{ fa_product_price }}",
        "itemCondition" : "http://schema.org/NewCondition",
        "availability" : "http://schema.org/{% if fa_current_variant.available %}InStock{% else %}OutOfStock{% endif %}",
        "url" : "{{ shop.url }}{{ fa_current_variant.url }}",
            {%- if fa_current_variant.image -%}
              {%- assign variant_image_size = fa_current_variant.image.width | append: 'x' -%}
              "image": "https:{{ fa_current_variant.image.src | img_url: variant_image_size }}",
            {%- else -%}
              "image": "https:{{ product.featured_image.src | img_url: '1500x1500' }}",
            {%- endif -%}
            {%- if fa_current_variant.title != 'Default Title' -%}
              "name" : "{{ product.title | strip_html | escape }} - {{ fa_current_variant.title | escape }}",
            {%- else -%}
              "name" : "{{ product.title | strip_html | escape }}",
            {%- endif -%}
            {%- if fa_current_variant.barcode.size >= 12 and fa_current_variant.barcode.size <= 14 -%}
              "gtin": {{ product.variants.first.barcode }},
            {%- endif -%}
			        "sku": "{{fa_product_id_value}}",
            {%- if product.description != blank -%}
            "description" : {{ product.description | strip_html | json }},
            {%- endif -%}
          "priceValidUntil": "{{ 'now' | date: '%s' | plus: 31536000 | date: '%Y-%m-%d' | uri_encode | replace:'+','%20' }}"
      }
    {%- if product.variants.size > 1 -%},
      "additionalProperty": [{
        "@type": "PropertyValue",
        "propertyID": "item_group_id",
        "value": "{{ product.id }}"
      }]
      {%- endif -%}
    {%- if product.metafields.spr.reviews -%}
    {%- assign fa_rating = product.metafields.spr.reviews | split: '"reviewCount": "' | last | split: '"' | first | plus: 0 -%}
    {%- if fa_rating > 0 -%}
    ,"aggregateRating": {
     "@type": "AggregateRating",
     "ratingValue": {{ product.metafields.spr.reviews | split: '"ratingValue": "' | last | split: '"' | first | plus: 0 }},
     "ratingCount": {{ product.metafields.spr.reviews | split: '"reviewCount": "' | last | split: '"' | first | plus: 0 }}
    }
    {%- endif -%}
    {%- endif -%}
  {%- endif -%}
}
</script>
{%- endif -%}
<!-- Copyright FeedArmy 2022 Version 3.18 -->

Once the new coding has been added, it will take Google Merchant Center several days before the warnings inside your diagnostic panel disappear. The reason it takes so long is that Google does not check every page every day.

Here is a step by step guide on how to paste the code in your products.liquid file.

Installing The Code

  1. Log in to your Shopify Admin Panel
  2. Go to Online Store > Themes
  3. In the top right corner, click on actions. A menu will appear, and click on Edit Code
Edit Shopify Theme Code
  1. Click on Templates > product.liquid
    • If you are using Dawn 2.0 or you don’t have product.liquid, install the code on Layout > theme.liquid, inside the <body> tag.
Shopify Product Liquid File
  1. The recommended place to paste the code is at the top. After installing the code, check that you did not break anything by checking the preview results of your product landing page.
  1. Remove the original Shopify review structured data, if you have added the widget in sections/product-template.liquid. This needs to be removed to ensure there are no warnings or errors. Search and replace the below code.

Search for:

<div id="shopify-product-reviews" data-id="{{product.id}}">{{ product.metafields.spr.reviews }}</div>

Replace with:

<div id="shopify-product-reviews" data-id="{{product.id}}"></div>
  1. Checking the results

Verify that you have done it correctly by checking the page with Google’s Structured Data Testing Tool

And also, check Facebook’s data testing tool.

You will see 1 warning

  • The review field is recommended. Please provide a value if available.
    • This can’t be added and should be added by the review app you are using.

You may also see other warnings. If you have not added all the values in Shopify, the most common missing values are Brand and GTIN. If you want these to show, make sure that you add Vendor and Barcodes in Shopify.

The aggregatedReviews in this script only extract data for the default Shopify review system, if you have other review systems such as yotpo, stamped, judgeme, loox, etc… then please contact me at the bottom of this article for a custom installation.

Google Structured Data Testing Result

If you want to succeed in your advertising efforts, why not hire a Google Shopping Specialist!

Fix Opengraph

A newly found issue for a few months now is related to Opengraph. It seems that sometimes Google looks at the Opengraph Price Amount. The issue here is that in most cases it will show the first variant that you created in Shopify. Instead of the selected variant. I did not mention this prior to 30th of April 2021, however Optily a merchant confirmed the existence of this issue and I have now decided to update this article to fix this issue too.

Step 1) Edit Liquid File

Go to:

  1. Open Your Shopify Admin
  2. Click from the left hand menu on Online Store
  3. Select Themes
  4. From the file folder navigate to the folder Snippets
  5. Open social-meta-tags.liquid
Shopify Edit Social Meta Tags Liquid

Step 2) Replace Coding

Near the bottom of the file you will see two lines wrapped inside an if statement that checks if the page is equal to product.

{% if template.name == 'product' %}
  <meta property="og:price:amount" content="{{ product.price | money_without_currency | strip_html }}">
  <meta property="og:price:currency" content="{{ shop.currency }}">
{% endif %}
Social Meta Tags Liquid Pricing Issue

Replace the above code with the below code.

{% if template.name == 'product' %}
	{%- assign fa_current_variant = product.selected_or_first_available_variant -%}
	{%- if cart.currency.iso_code == 'GBP' or cart.currency.iso_code == 'USD' or cart.currency.iso_code == 'AUD' or cart.currency.iso_code == 'AED' or cart.currency.iso_code == 'CAD' or cart.currency.iso_code == 'BWP' or cart.currency.iso_code == 'BND' or cart.currency.iso_code == 'DOP' or cart.currency.iso_code == 'GTQ' or cart.currency.iso_code == 'HKD' or cart.currency.iso_code == 'INR' or cart.currency.iso_code == 'ILS' or cart.currency.iso_code == 'YEN' or cart.currency.iso_code == 'KES' or cart.currency.iso_code == 'KOR' or cart.currency.iso_code == 'LBP' or cart.currency.iso_code == 'MYR' or cart.currency.iso_code == 'MXN' or cart.currency.iso_code == 'NPR' or cart.currency.iso_code == 'NZD' or cart.currency.iso_code == 'NIO' or cart.currency.iso_code == 'NGN' or cart.currency.iso_code == 'PKR' or cart.currency.iso_code == 'CNY' or cart.currency.iso_code == 'PHP' or cart.currency.iso_code == 'SGD' or cart.currency.iso_code == 'LKR' or cart.currency.iso_code == 'CHF' or cart.currency.iso_code == 'TWD' or cart.currency.iso_code == 'TSH' or cart.currency.iso_code == 'THB' or cart.currency.iso_code == 'UGX' or cart.currency.iso_code == 'KWD' or cart.currency.iso_code == 'CLP' or cart.currency.iso_code == 'BHD' -%}
    {%- assign fa_product_price = fa_current_variant.price | money_without_currency | remove:',' -%}
    {%- else -%}
    {%- assign fa_product_price = fa_current_variant.price | money_without_currency | remove:'.' | replace: ',', '.' -%}
    {%- endif -%}
    <meta property="og:price:amount" content="{{ fa_product_price }}">
    <meta property="og:price:currency" content="{{ cart.currency.iso_code }}">
{% endif %}

It should look like the image below.

Shopify Opengraph correct pricing

For this to work, you do need to install my structured data at the top of the page.

Change Log

  • V3.18 – 15 November 2022: Added GTIN empty check
  • V3.15 – 19 October 2022: Removed individual GTIN attributes (gtin12,gtin13,gtin14) and replaced it with gtin for all values
  • V3.14 – 07 October 2022: Changed image URL from Grande to 1500×1500 pixels
  • V3.13 – 01 October 2022: Added Bahrain currency detection
  • V3.12 – 12 June 2022: Removed GTIN validation due to scenarios where numeric values are provided as strings
  • V3.11 – 14 April 2022: Added extra GTIN validation
  • V3.10 – 15 February 2022: Added @id value
  • V3.09 – 01 December 2021: Added AED currency detection
  • V3.08 – 09 October 2021: Added Canadian currency detection
  • V3.07 – 04 October 2021: Updated Brand attribute
  • 13 September 2021: Updated opengraph code
  • V3.06 – 25 August 2021: Updated SKU attribute to escape special characters
  • V3.05 – 19 August 2021: Updated currency detection to include Chilean Peso
  • V3.04 – 17 July 2021: Updated list of dot delimiter used in countries

Need Help?
Do You have a question or need specialist support? Get in touch!

Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

210 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
Boris
Boris
2 months ago

I customized JSON so it shows different currency according to location determined by subdomain.
By the way I need to show price amount according to currency.
Is there any way for that?
Thanks.

Boris
Boris
Reply to  Emmanuel Flossie
2 months ago

Hi Emmanuel!
The price on our product page is changing according to default Shopify currency converter.
As you know it seems not possible to change the price in JSON/LD via API or JavaScript code.

François
François
3 months ago

Thanks for that!

Could you explain why you did:

{%- if fa_current_variant.barcode.size == 12 -%}
"gtin12": {{ fa_current_variant.barcode }},
{%- endif -%}
{%- if fa_current_variant.barcode.size == 13 -%}
"gtin13": {{ fa_current_variant.barcode }},
{%- endif -%}
{%- if fa_current_variant.barcode.size == 14 -%}
"gtin14": {{ fa_current_variant.barcode }},
{%- endif -%}

Instead of:

 "gtin": {{ fa_current_variant.barcode }},

I searched google, but I don’t get it. 🙂

Dylan
9 months ago

Hello,

The most recent version (3.10) seems to have issues looping through variants.

as an example has 3 variants listed, however it only seems to create an offer for the 1st variant and not the remaining variants.

Mr.Kiddie
10 months ago

Hi, I still having brand type issue in my site. can you check how we can resolve manually?

AM
AM
1 year ago

Hey!

First, thanks for making this available!

I am running Dawn Theme version 2.4.0.

I installed your code “The Code” as instructed, at the top of the “Body” section in “theme.liquid”.

(1) When I run a “Shema Markup Validator” test, it returns results without errors, but it indicates there are two products.

(2) When I test the “Live URL” on Google’s Search Console, it also indicates there are two products. The first product still has all the six errors I had prior to installing “The Code” and the second product (which I assume is being provided by your code) only has three errors (two of which are related to reviews and I can’t remember the third).

At this point I reverted back to my original “theme.liquid” and thought it’d be best to contact you.

Thanks in advance for any help you can provide, AM.

Hamza Sellak
Hamza Sellak
1 year ago

Hi @EMMANUEL; I’m in exactly the same position as @OMRI; I’m using Dawn 2.0 and I cannot find any of the files you mentioned. Can you please help me as I’ve been running into the “Mismatched value (page crawl) [price]” problems for days and I couldn’t find any solution to this problem. I’d appreciate if you can help me with this. Thanks in advance.

Omri Weiss
1 year ago

Hi,
you wrote on the article to write you down here if I am using other app for reviews than the basic Shopify one for code modification.

I am using Judge.me app for reviews. Can you please help me with the code customization to fix the issue?

Please help me

Jules
Reply to  Emmanuel Flossie
1 year ago

Hello Emmanuel!

Sorry to drop into the conversation, but I think this code may help us resolve the pesky mismatched price warning for variants we are seeing, but we use Loox for reviews. Would it be possible to get assistance with this? You mentioned to comment here if we use a different review system, so I am.

Thanks in advance for any assistance you can provide! 🙂
Jules

Gunnar
1 year ago

Just to let you know, Shopify has included the structured data again in their new Dawn theme and now it appears in the main-product section.

Gunnar
1 year ago

Hi Emmanuel,

I’m currently using your code in my customized Debut theme, but I’m in the process of migrating to the new Shopify 2.0 Dawn theme. In their new set up I can’t find the structured data anywhere, the product.liquid is now a json file and in the main-product.liquid section is no mention of structured data either (I checked all the other sections and snippets too, to be sure). Where should I paste this code now and why would they have decided not to include it anymore in the Dawn theme?
Thanks in advance, much appreciated.

Kenneth
1 year ago

Hi Emmanuel

Thank for the 3.02 update. However, I’m not sure if it supports my DKK currency? Previously versions had the ‘false’ parameter for European currency format.

DKK is also 1.000,00 – but from how I read the code, it only changes from 1,000.00 to 1.000,00 if the currency is EUR, right?

I don’t have much coding knowledge, so I just wanted to be sure before I update. I’m running af multi-currency store with both DKK, USD, EUR, CAD, AUD and SEK.

Mehdi Dar
Mehdi Dar
1 year ago

Hi, when google crawls, it doesn’t seem to get the actual right prices.When i test my structured data, prices appear without a “,”.But I did everything as you told and it doesn’t work. Do you know how i can make it work ?Price is supposed to be 99,90€ https://uploads.disquscdn.c

Albert Gouws
Albert Gouws
2 years ago

Hi, I recently tried your snippet for my shopify site. It seems like json validators (and google) doesn’t like my description field containing new lines. My description field is quite long and it fails on that.Below is the output, which shows my long description field.Any ideas on this?Thanks!{ “@context”: “http://schema.org/”, “@type”: “Product”, “name”: “Singer Heavy Duty 4432 *** ON SPECIAL ***”, “url”: “https://sewingmachinecentre.nz/products/heavy-duty-4432″,”sku”: “Singer-4432″,”productID”: “3670132228148”, “brand”: { “@type”: “Thing”, “name”: “Singer” }, “description”: “The big brother of the Singer Heavy Duty 4423, the Singer Heavy Duty 4432 offters an additional 9 stitch types over the Singer HD 4423. The Singer HD4432 offers more room to grow as a sewist and is a very robust machine, which means it will stand the test of time.With a heavy-duty metal interior frame, stainless steel bed plate, extra-high sewing speed and powerful motor this is a true work horse. It comes complete with automatic needle threader (sewing’s biggest time saver) and the machine’s 1,100 stitches per minute speed allows you to bring your creative ideas to life quickly.Features32 Built-in Stitches50 Stitch FunctionsLED lighting –brighter lightingAutomatic 1-step ButtonholeAutomatic Needle ThreaderExtra High Speed Sewing –1,100 stitches per minuteStainless Steel Bed PlateAdjustable Presser Foot PressureHorizontal Thread DeliveryExtra High Presser Foot LiftDrop Feed SystemProvision for Mounting in Cabinet or TableReverse OperationFree-Arm DesignInstruction ManualHeavy Duty Metal FrameMetal Bobbin WinderAuto TensionTop Drop-In Bobbin SystemVariable Stitch LengthVariable Stitch WidthAuto Bobbin WindingSnap on Presser FeetBuilt-In StorageIncluded Accessories General Purpose FootButton Sewing FootButtonhole FootZipper FootEdge / Quilting GuideSeam Ripper / Lint BrushBobbinsSpool CapsAuxiliary Spool PinsSpool Pin FeltL-ScrewdriverPack of NeedlesDust Cover”, “image”: “https://cdn.shopify.com/s/files/1/0070/6327/3524/products/4432_Global_beauty_baa9e82b-4316-469e-80be-384920aaf1f2_grande.png?v=1557885939″,”offers”: { “@type” : “Offer”, “priceCurrency”: “NZD”, “price”: “539.00”, “itemCondition” : “http://schema.org/NewCondition”, “availability” : “http://schema.org/InStock”, “url” : “https://sewingmachinecentre.nz/products/heavy-duty-4432?variant=28543676121140″,”image”: “https://cdn.shopify.com/s/files/1/0070/6327/3524/products/4432_Global_beauty_baa9e82b-4316-469e-80be-384920aaf1f2_grande.png?v=1557885939″,”name” : “Singer Heavy Duty 4432 *** ON SPECIAL ***”,”sku”: “Singer-4432″,”description” : “The big brother of the Singer Heavy Duty 4423, the Singer Heavy Duty 4432 offters an additional 9 stitch types over the Singer HD 4423. The Singer HD4432 offers more room to grow as a sewist and is a very robust machine, which means it will stand the test of time.With a heavy-duty metal interior frame, stainless steel bed plate, extra-high sewing speed and powerful motor this is a true work horse. It comes complete with automatic needle threader (sewing’s biggest time saver) and the machine’s 1,100 stitches per minute speed allows you to bring your creative ideas to life quickly.Features32 Built-in Stitches50 Stitch FunctionsLED lighting –brighter lightingAutomatic 1-step ButtonholeAutomatic Needle ThreaderExtra High Speed Sewing –1,100 stitches per minuteStainless Steel Bed PlateAdjustable Presser Foot PressureHorizontal Thread DeliveryExtra High Presser Foot LiftDrop Feed SystemProvision for Mounting in Cabinet or TableReverse OperationFree-Arm DesignInstruction ManualHeavy Duty Metal FrameMetal Bobbin WinderAuto TensionTop Drop-In Bobbin SystemVariable Stitch LengthVariable Stitch WidthAuto Bobbin WindingSnap on Presser FeetBuilt-In StorageIncluded Accessories General Purpose FootButton Sewing FootButtonhole FootZipper FootEdge / Quilting GuideSeam Ripper / Lint BrushBobbinsSpool CapsAuxiliary Spool PinsSpool Pin FeltL-ScrewdriverPack of NeedlesDust Cover”,”priceValidUntil”: “2021-06-05″ },”aggregateRating”: { “@type”: “AggregateRating”, “ratingValue”: 5.0, “ratingCount”: 1 }}

Vishesh
Vishesh
2 years ago

Hello the code is not working for me it is still showing me all those errors. I completely replaced everything in product.liquid file with what you said and I can find the code in product-related.liquid. Still getting the same errors. Please help

Diego
Diego
2 years ago

Hi, i tried to change from “priceCurrency”: “{{shop.currency}}”,to: “priceCurrency”: “{{ cart.currency.iso_code }}”,and it seems work

Diego
Diego
2 years ago

Hi, we installed your code, we have a question: we have multple currencies on our store, if we test the structured data we have no error but the currency in the data is always EUR also by entering the direct link for the currency in GBPon the feed and on the website the right currencies are displayed but the bot on the structured data test crawl always the default shop currency (EUR) can we fix it?

caapo
caapo
2 years ago

Where on the page do you embed this script? Just after the review code? <div id=”shopify-product-reviews” data-id=”{{product.id}}”></div>This should ensure Rich Results and googlebot does not pick up the duplicate content?

caapo
caapo
Reply to  Emmanuel Flossie
2 years ago

Yes correct. It appears in both ‘view source’ and ‘inspect’. Duplicated generated automatically by Shopify Product Reviews App. Looking for a way to disable it so only one version shows. Remove the meta details as per above comments also and it still shows up. Did you get the script working? Where did you embed it?

Joost Plas
Joost Plas
2 years ago

Hey Emmanuel. Thanks for replying. Really appreciate the effort.I think I got my confusion:- If you remove {{ product.metafields.spr.reviews }} the JSON doesn’t appear in the page source (server response), but does appear in ‘inspect element’ (client side rendering).- How I interpret this:– removing it is sufficient to prevent any errors for the Google bots– adding my additional JS (.remove() ), will not have effect on Google Bots, but also cannot hurt and is more for my personal satisfaction that the duplicating is not ending up in browser parsed code.Does that make sense to you?

Joost Plas
Joost Plas
Reply to  Emmanuel Flossie
2 years ago

Check the comments from Emmanuel. It looks like you don’t need that JS. First check if you see the duplicated JSONO when you check your HTML (view source, not through inspect).

Rajan Dimri
Rajan Dimri
2 years ago

Hello,Thanks for this contribution.Currently I’m getting the three errors – https://uploads.disquscdn.c…How can I fix these issues?

Joost Plas
Joost Plas
2 years ago

It looks like Shopify has updated their review app? When I remove {{ product.metafields.spr.reviews }} it still loads the JSON from the app, resulting in duplicates. Any tip how to prevent this from happening?

Joost Plas
Joost Plas
Reply to  Joost Plas
2 years ago

I think I figured it out, so for reference:<script> var SPRCallbacks = { onProductLoad: function( e ) { $(‘#shopify-product-reviews [type=”application/ld json”]’).remove(); }, onReviewsLoad: function( e ) { $(‘#shopify-product-reviews [type=”application/ld json”]’).remove(); } } </script>

Darcy
Darcy
2 years ago

Hi, Thank you so much for this code!I just have one question, I’m using Loox as my review app. It seems that Loox has already add the schema code by itself.Can I just delete this review code to avoid warning? {%- if product.metafields.spr.reviews -%} ,”aggregateRating”: { “@type”: “AggregateRating”, “ratingValue”: {{ product.metafields.spr.reviews | split: ‘”ratingValue”: “‘ | last | split: ‘”‘ | first | plus: 0 }}, “ratingCount”: {{ product.metafields.spr.reviews | split: ‘reviewCount”: “‘ | last | split: ‘”‘ | first | plus: 0 }} } {%- endif -%}Best RegardsDarcy

Darcy
Darcy
Reply to  Emmanuel Flossie
2 years ago

Thank you very much! I’m sending you an email right now!Best RegardsDarcy

Chase Hundley
Chase Hundley
2 years ago

I am getting this error after using your tutorial. Any advice? https://uploads.disquscdn.c

Shraddha Mistry
Shraddha Mistry
2 years ago

https://uploads.disquscdn.c… I am facing issue on product page all the other fields are solved expected this two 1.aggregateRating 2. reviewI have used this code <meta itemprop=”image” content=”https:{{ product.featured_image.src | img_url: ‘grande’ }}”/> {% if product.variants.first.barcode == blank %} <meta itemprop=”gtin8″ content=”-“/> {% else %} <meta itemprop=”gtin8″ content=”{{ product.variants.first.barcode }}”/> {% endif %} <meta itemprop=”brand” content=”{{ product.vendor }}”/> <meta itemprop=”sku” content=”{{ product.variants.first.sku }}”/>and for reviews <div id=”shopify-product-reviews” data-id=”{{product.id}}”></div>

Ben Fuhrmann
Ben Fuhrmann
2 years ago

Hi,the code works very well but I am having trouble with the price. Since we are using the German presentation of prices we are using a “,” instead of “.” to separate decimal places (19,95€ instead of 19.95€). The structured data now shows all prices without a “,”, resulting in 1995€.I have removed the “remove: ‘,’ ” portion of your code but that doesn’t fix the problem. How can I fix the error?

Ben Fuhrmann
Ben Fuhrmann
Reply to  Ben Fuhrmann
2 years ago

Nevermind, I just fixed the error. For anyone else from Germany having the same problem: You need to edit the general settings of your shopify store and change the currency formatting to {{amount}}. In our store was initially set to {{amount_with_comma_separator}}.

Colinas Store
Colinas Store
2 years ago

Hello, the code works very well for all the fields except for the notices, I still have 3 warnings about the aggregated notices .. however I have your tutorial correctly

Shraddha Mistry
Shraddha Mistry
2 years ago

https://uploads.disquscdn.c… I am getting this error only for two product page

Toby Zuijdveld
Toby Zuijdveld
2 years ago

Thank you SO MUCH! Great work here. Well done.However using the Facebook testing tool it reports the following Errors:A required field is missing: id (Products without “id” information can’t be uploaded. Please check that this field is included for each product in a separate, labeled column.)A required field is missing: availability (Products need to have availability listed to run in ads. Include the current availability for each product in your data feed file and upload it again. You can only add the supported values “in stock”, “out of stock”, “preorder”, “available for order”, “discontinued”, “pending” in US English under the “availability” column.)And the following Warning:A product is missing a field: google_product_category (Without google_product_category information, your products may not appear the way you want them to in ads.)Looks like availability is there but there is a conflict between the values Google and Facebook will accept (Facebook seems to expect spaces?)

Sheikh Munawar
Sheikh Munawar
2 years ago

Thank you very much. It is working now https://uploads.disquscdn.c

John Baker
John Baker
2 years ago

Thanks Emmanuel again for updated code – version 2.34 – working fine for reviewed product(s)https://uploads.disquscdn.c…

Tim Carillo
Tim Carillo
2 years ago

I’m having 2 new errors from Google that say the following:Rating is missing required best and/or worst valuesValue in property “ratingCount” must be positiveAll of my products have reviews and so I’m confused but the code is putting out that the aggregate rating is showing my ratingValue and ratingCount as 0. Any idea what would be causing this?

Tim Carillo
Tim Carillo
Reply to  Tim Carillo
2 years ago

This same thing also happened to me and I am using Shopify’s default review app along with the brooklyn theme. Any ideas?

Tim Carillo
Tim Carillo
Reply to  Tim Carillo
2 years ago

Same problem.I went down the rabbit hole at this to no success.https://community.shopify.c

Sheikh Munawar
Sheikh Munawar
2 years ago

Code was working just fine, untill today “ratingValue”: “ratingCount”: have started returning “0” value.

210
0
Would love your thoughts, please comment.x
()
x