Mobile app version of vmapp.org
Login or Join
Harper822

: How to add AggregateRating in GTM using DOM element Variables? Here is the JSON-LD script that i use for implementing product schema in GTM using DOM variables. <script> var jsonData = {

@Harper822

Posted in: #GoogleTagManager #JsonLd #SchemaOrg

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:





But while debugging the page, the avgRating and ratingsCount value showing 'null'.



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..

10% popularity Vote Up Vote Down


Login to follow query

More posts by @Harper822

0 Comments

Sorted by latest first Latest Oldest Best

Back to top | Use Dark Theme