2

Here is the JSON-LD script that i use for implementing product schema in GTM using DOM variables.

<script>
var jsonData = {
  "@context": "http://schema.org",
  "@type": "Product",
  "name": {{productName}},
  "image": {{productImg}},
  "url": {{Page URL}},
  "aggregateRating": {
    "@type": "AggregateRating",
"ratingValue": {{avgRating}},
    "reviewCount": {{ratingsCount}},
  }
  }

  var script = document.createElement('script');
  script.type = 'application/ld+json';
  script.text = JSON.stringify(jsonData);
  $("head").append(script);
</script>

DOM Variable Configuration:

enter image description here

enter image description here

But while debugging the page, the avgRating and ratingsCount value showing 'null'.enter image description here

enter image description here

I am unable to find out where is the main error that the value not being extract from the page. How can i solve the problem..Please mention if there is any error in the schema code and the DOM variable configuration. Thanks in Advance..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.