所以我使用以下代码来实现客户评论徽章。
<script src="https://apis.google.com/js/platform.js?onload=renderBadge"
async defer>
</script>
<script>
window.renderBadge = function() {
var ratingBadgeContainer = document.createElement("div");
document.body.appendChild(ratingBadgeContainer);
window.gapi.load('ratingbadge', function() {
window.gapi.ratingbadge.render(
ratingBadgeContainer, {
"merchant_id": 42,
"position": "BOTTOM_LEFT"
});
});
}
</script>
<!-- END GCR Badge Code -->
<!-- BEGIN GCR Language Code -->
<script>
window.___gcfg = {
lang: 'en_US'
};
</script>
<g:ratingbadge merchant_id=MERCHANT_ID></g:ratingbadge>
但是是否有可能使其在本地计算机上运行?
另外,本地计算机是指在我的计算机上运行 Visual Studio 解决方案。因此它不在可公开访问的网站中。
干杯
最佳答案
好吧,我明白了,
事实证明,徽章不会在本地计算机上呈现 http://localhost
我从谷歌获得的客户评论代码也是通过谷歌标签管理器实现的。 经过分析,徽章未呈现,因此当我将客户评论代码添加到页脚(因此不通过标签管理器)时,它正在工作。
Conclusion
The google customer reviews code must be on the live server to work.(So not http://localhost) etc.
The code must be included directly in the theme files. NOT THROUGH GOOGLE TAG MANAGER
关于javascript - 是否可以在本地机器上测试Google客户评论徽章,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44938922/