0

I'm trying to set up a facebook purchase event in GTM and i'm almost there but i son't understand why I can only see the first product from the transactiuon array in facebook business manager? I can see that a transaction been made and I can see the value but only one product SKU!

This is the datalayer after a specifik purchase, with two different kind of tickets:

{
    transactionId: "31000226",
    transactionTotal: 243,
    transactionProducts: [
        {
            name: "Adult",
            sku: "Adult",
            price: 135,
            quantity: 1,
            category: "tickets"
        },
        {
            name: "Pensioner",
            sku: "Pensioner",
            price: 108,
            quantity: 1,
            category: "tickets"
        }
    ],

And this is my GTM-tag for the facebook purchase event:

<script>
  fbq('track', 'Purchase',{
    products: '[{{DLV - Ecommerce - Product}}]',
    value: '{{DLV - Ecommerce - TransactionTotal}}',   
    currency: 'SEK'
  });
</script>

The datalayer variable {{DLV - Ecommerce - Product}} is set up like this in GTM:

transactionProducts.0.sku

This is what I can see in facebook business manager:

Parametrar: (3)

value: 243

currency: SEK

products: [Adult]

Does anyone see the problem? Why can't I in this exampel see the second ticket that says "Pensioner"?

Gustav
  • 3
  • 4

1 Answers1

0

You could write a custom variable “sku variable” for the sku to be the below:

function () {
{{DLV - Ecommerce - Product}}.forEach {
return sku
};
}

Change the {{DLV - Ecommerce - Product}} to just transactionProducts

Jesse
  • 156
  • 5
  • thanks! should I have products: '[{{DLV - Ecommerce - Product}}]' in the pixel-event or should it be products: '[{{New SKU varible CJ}}]'? – Gustav Oct 17 '19 at 08:45
  • It should be products: ‘{New SKU variable CJ}} as that variable should return an array so no need to add the array [] around the variable. – Jesse Oct 17 '19 at 10:48
  • when I try it ut in the console I get an error about the { after forEach. Why is that? This is what i says in the error messeage: "Uncaught SyntaxError: Unexpected token '{'" – Gustav Oct 17 '19 at 11:45
  • Sorry forgot a } try - function () { {{DLV - Ecommerce - Product}}.forEach { return sku }} – Jesse Oct 17 '19 at 19:10