# Use the ecommerce datalayer for GA4 ecommerce

**URL:** <https://community.piwik.pro/t/use-the-ecommerce-datalayer-for-ga4-ecommerce/1342>\
**Category:** Data collection and tags\
**Created:** [December 8, 2022, 2:18pm UTC](https://community.piwik.pro/t/use-the-ecommerce-datalayer-for-ga4-ecommerce/1342 "2022-12-08T14:18:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ValPiwik](https://avatars.discourse-cdn.com/v4/letter/v/ecd19e/32.png) [@ValPiwik](https://community.piwik.pro/u/ValPiwik)\
**Post date:** [December 8, 2022, 2:18pm UTC](https://community.piwik.pro/t/use-the-ecommerce-datalayer-for-ga4-ecommerce/1342/1 "2022-12-08T14:18:01Z")

</div>

Hi,

I would like to trigger the GA4 “purchase” event through Piwik PRO TMS.  
We use the Piwik PRO order\_confirmation datalayer.

I created 1 datalayer variable per element.

And bellow event I would like to push:

```auto
<script>
  gtag("event", "purchase", {
    transaction_id: {{ DLV | Ecommerce | order_id }},
    value: {{ DLV | Ecommerce | grand_total }},
    currency: "EUR",
    items: [
     {
      item_id: {{ DLV | Ecommerce | product.sku }},
      item_name: {{ DLV | Ecommerce | product.name }},
      item_category: {{ DLV | Ecommerce | product.catagory }},
      price: {{ DLV | Ecommerce | product.price }},
      quantity: {{ DLV | Ecommerce | product.quantity }},
    }]
});
</script>

Make it sense?
If I have several products in my purchase, is it going to automatically add more item?

Many thanks,
```

---

<div class="post-metadata">

**Author:** ![pslonina](https://dub1.discourse-cdn.com/flex005/user_avatar/community.piwik.pro/pslonina/32/1711_2.png) [@pslonina](https://community.piwik.pro/u/pslonina)\
**Post date:** [December 9, 2022, 8:59am UTC](https://community.piwik.pro/t/use-the-ecommerce-datalayer-for-ga4-ecommerce/1342/2 "2022-12-09T08:59:07Z")

</div>

Hello @ValPiwik ,  
Did you have a chance to look into this article [How to set up ecommerce tracking? - #2 by pp.support](https://community.piwik.pro/t/how-to-set-up-ecommerce-tracking/79/2)? The data layer structure is different, but it’s just a matter of adjusting the variables. Please make sure there is a loop that iterates through the cart (you need to add each product separately). You can use the [tracker debugger](https://help.piwik.pro/support/collecting-data/tracker-debugger/) to check if the variables were correctly assigned.

Thanks,  
Piotr

---

<div class="post-metadata">

**Author:** ![Admin](https://avatars.discourse-cdn.com/v4/letter/a/3ec8ea/32.png) [@Admin](https://community.piwik.pro/u/Admin)\
**Post date:** [March 9, 2023, 10:29am UTC](https://community.piwik.pro/t/use-the-ecommerce-datalayer-for-ga4-ecommerce/1342/3 "2023-03-09T10:29:31Z")

</div>



---

<div class="post-metadata">

**Author:** ![Admin](https://avatars.discourse-cdn.com/v4/letter/a/3ec8ea/32.png) [@Admin](https://community.piwik.pro/u/Admin)\
**Post date:** [March 9, 2023, 10:29am UTC](https://community.piwik.pro/t/use-the-ecommerce-datalayer-for-ga4-ecommerce/1342/4 "2023-03-09T10:29:43Z")

</div>


