Fetch variables from 'purchase' event

Hi all,

I need some help fetching the variables from my ‘purchase’ Event.

The event is recognized by the TagManager Debug mode, but not by the Tracker Debugger in Analytics.

I copied the tag setup from the solution gallery (Solution Templates | Piwik PRO) and inserted my dataLayer variables.

According to the TagManager Debugger, the Tag fires correctly:
image

But the Analytics Debugger does not show it:

My E-Commerce Tag Setup is:

(function () {

  window._paq = window._paq || [];
  var products = {{ items }}.map(function(product) {
    return {
      sku: items.id,
      name: items.name,
      price: items.price,
      quantity: items.quantity
    };
  });
  
  var paymentData = {{  }};
  var paymentInformation = {
      orderId: transaction_id,
      grandTotal: value,
      tax: tax,
      shipping: shipping
  };
  
  _paq.push(["ecommerceOrder", products, paymentInformation]);  

    })();

and the dataLayer that gets transmitted with the ‘purchase’ event looks like:

What am I missing?
Any help would be appreciated!

Hi,
Could you share the name of a URL to the website that you are referring to?
You can leave it here under the thread or send it to me via private message.

Hi Adam, thanks for the speedy reply. the URL in question is www.flume.de

Could you please share what the purchase event objects look like in your data layer?

this is the dataLayer for the ‘purchase’ event. it is a legacy UA integration that I’m trying to work with.

{
  "event": "purchase",
  "transaction_id": xxx,
  "items": [
    {
      "id": "xxxx",
      "name": "xxxx",
      "quantity": 1,
      "price": 1.35,
      "currency": "EUR"
    }
  ],
  "currency": "EUR",
  "shipping": "",
  "value": 9.82,
  "tax": 1.57
}

The issue here is that you map a variable in the curly brackets that does not exist in Piwik PRO’s Tag Manager. I will create a DL variable will map the correct ecommerce items and in 10 minutes or so you could check if everything works as intended. The curly brackets refer to variables in our Tag Manager. You can find more information about variables here: How to use variables in tags and triggers | Piwik PRO help center

1 Like

Thank you so much for the help, I will take a short lunch break and be ready to implement the fixed variables after.

I fixed the DL variable. Based on the variable you could try adopting the same formula to the rest of your payment variables.

Thanks, Adam. I’ve mapped the rest of the variables according to your example and plugged them into the tracking tag. the code now looks like this (pls excuse the German, trying to keep it understandable for the customer):

<script>
  (function () {

  window._paq = window._paq || [];
  var products = {{ Purchase Items - DLV }} }}.map(function(item) {
    return {
      sku: {{ Produkt ID }},
      name: {{ Produktname }},
      price: {{ Produktpreis }},
      quantity: {{ Produktanzahl }}
    };
  });
  
  var paymentData = {{  }};
  var paymentInformation = {
      orderId: {{ Bestellungs ID }},
      grandTotal: {{ Bestellwert }},
      subTotal: {{ Bestellwert }} - {{ Steuern }} - {{ Versandkosten }},
      tax: {{ Steuern }},
      shipping: {{ Versandkosten }}
  };
  
  _paq.push(["ecommerceOrder", products, paymentInformation]);  

    })();
</script>

I am still facing the same issue however. The Tagmanager Debugger shows the Tag as firing, but the Analytics Debugger does not.

image

Replace {{ Produkt ID }}, {{ Produktname }} and so on with the objects that you have within your dataLayer object. The structure should look the following way:

var products = {{ Purchase Items - DLV }} }}.map(function(item) {
    return {
      sku: item.id,
      name: item.name,
      price: item.price,
      quantity: item.quantity
    };
  });

done, issue unfortunately persists.

my tag now (tested with ‘items.’ instead of ‘item.’ as well, same problem)

<script>
  (function () {

  window._paq = window._paq || [];
  var products = {{ Purchase Items - DLV }} }}.map(function(item) {
    return {
      sku: item.id,
      name: item.name,
      price: item.price,
      quantity: item.quantity
    };
  });
  
  var paymentData = {{  }};
  var paymentInformation = {
      orderId: transaction.id,
      grandTotal: value,
      subTotal: value - tax - shipping,
      tax: tax,
      shipping: shipping
  };
  
  _paq.push(["ecommerceOrder", products, paymentInformation]);  

    })();
</script>

I have noticed that the purchase event fires before the first page view event. Could this cause an issue?

image