如何使用谷歌标签管理器删除 magento 默认架构标记?

时间:2021-08-01 13:25:09

标签: javascript dom magento google-tag-manager

我无法使用谷歌标签管理器从 DOM 页面中删除默认项目类型和项目类型。 enter image description here

如何在谷歌标签管理器中使用 javascript 从上面的 body 标签中删除 itemtype 和 itemscope?

2 个答案:

答案 0 :(得分:0)

您可以使用 Element.removeAttribute() 方法从元素中删除所需的属性。在这种情况下,您可以执行以下操作:

document.body.removeAttribute("itemtype");
document.body.removeAttribute("itemscope");

答案 1 :(得分:0)

这可以通过在谷歌标签管理器中添加这个自定义 HTML 标签来完成:

<script>
var body = document.getElementsByTagName('body')[0];

body.removeAttribute("itemtype");
body.removeAttribute("itemscope");
</script>