首页 > 解决方案 > 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.

标签: javascriptwordpressgoogle-tag-manager

解决方案


推荐阅读