javascript - GTM - Creating a list of products in GTM - Wordpress
问题描述
Ahoy,
i am using built in gtm plugin on wordpress/woocomerce and it gets the following content:
cartContent: {
totals: {
applied_coupons: [],
discount_total: 0,
subtotal: "2844.715447",
total: "2844.715447"
},
items: [
{
id: "K-GG-V4-S",
name: "Grill Gazowy Koler Relish v4 5 palników 17,2kW",
sku: "K-GG-V4-S",
category: "Grille Gazowe",
price: 3499,
stocklevel: 41,
quantity: 1
},
{
id: "5900000002453",
name: "Fartuch Koler",
sku: "5900000002453",
category: "Wszystkie produkty",
price: 0,
stocklevel: null,
quantity: 1
},
{
id: "6600006666664",
name: "Pokrowiec + wąż i reduktor",
sku: "6600006666664",
category: "Wszystkie produkty",
price: 0,
stocklevel: null,
quantity: 1
}
]
},
but I have to implement the entire content of the basket into something that is to change dynamically depending on the number of products:
<script>
wph('track', 'AddToCart', {
content_type: 'category',
contents: [{
id: 'PRODUKT_ID1',
name: 'NAZWA_PRODUKTU1',
category: 'KATEGORIA_PRODUKTU1',
ean: 'PRODUKT_EAN_ID1',
price: 20.15,
in_stock: true
quantity: 1
weight : 'WAGA PRODUKTU'
}, {
id: 'PRODUKT_ID2',
name: 'NAZWA_PRODUKTU2',
category: 'KATEGORIA_PRODUKTU2',
ean: 'PRODUKT_EAN_ID2',
price: 20.15,
in_stock: true
quantity: 1
weight : 'WAGA PRODUKTU'
}]
})
</script>
How can I do this in GTM? I must admit that it was a bit too much for me, because I usually didn't need the entire basket.
解决方案
推荐阅读
- javascript - d3-venn / venn.js 维恩圈相互封闭
- asp.net-core - 修改 ASP .NET Core 中的登录页面文本
- reactjs - 无法在反应中对未安装的组件执行反应状态更新
- java - 无法解析 java.io.InputStream 依赖
- r - 在 Shinny Web 应用程序中绘制缺失状态图
- javascript - 是否可以在指定语言中进行文本区域拼写检查?
- javascript - 如何自定义 FirebaseUI-Web 的主题
- html - 具有奇数/偶数行自定义样式的动态 CSS 网格
- javascript - 在具有多个标头的 javascript 中使用 POST
- struct - 如何接受扩展 PartialEq 的盒装特征对象?