Print Item Number in Thank You page for Google Reviews

Highlighted
New Member
1 0 0

Hello,

 

We have the Google Reviews javascript on out Thank You page. I am trying to add the optional GTIN (Google product ID) of what customers purchased to this script. These two variables from Google Reviews js:

 

  "products": [{"gtin":"GTIN1"}, {"gtin":"GTIN2"}]

 

So far I have not been able to find the correct liquid variable(s) to replace "GTIN1" and "GTIN2" with.

 

Shopify Support told me to use  {{ variant.barcode }} - this gave a blank result. I have also tried:

 

{{ product.id }} - blank result
{{ product.id|json }} - result of "null"

 

The perplexing thing is that {{ product.id|json }} works perfectly in a different script on the same page. 

 

I found one article about this (https://www.digitaldarts.com.au/google-customer-reviews-shopify), which recommended using:

 

"products": [{% for item in order.line_items %}{"gtin":"{{ item.variant.barcode }}"}{% unless forloop.last %}, {% endunless %}{% endfor %}]

This code works for the second GTIN, but not the first. Result in source:

 

"products": [{"gtin":""}, {"gtin":"856862008018"}]

 

So I believe that is close but maybe needs a tweak?

 

Thank you to anyone who can help!

 

 

 

 

 

0 Likes