,我使用作为实施使用GTM DOM变量产品模式的自定义HTML标签的产品架构代码..如何使用DOM元素变量在GTM中添加AggregateRatingin?
<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元素变量在AggregateRating变量(avgRating,ratingsCount) GTM。
这里是标记
<div class="woocommerce-product-rating">
<div class="star-rating">
<span style="width:100%">
<strong class="rating">5.00</strong> out of <span>5</span> based on <span class="rating">1</span> customer rating </span>
</div>
<a href="#reviews" class="woocommerce-review-link" rel="nofollow">(<span class="count">1</span> customer review)</a> </div>
能否请您HTML标记添加到您的问题,因为我们需要了解在哪里可以找到它在你的标记 –
加入上面的HTML标记( avgrating,avgreviews).. –
我也尝试通过ID也类...但整个评论文章显示...但我想这些变量的平均整数值。我如何提取这些的确切的平均整数值.. –