From 0f7b39c3cbb4d4e200804e9deec2068817a869df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Rafael=20Siqueira?= Date: Tue, 13 May 2025 12:26:36 -0300 Subject: [PATCH] fix --- .../src/pages/_components/BuyButton.astro | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/superpage/src/pages/_components/BuyButton.astro b/superpage/src/pages/_components/BuyButton.astro index de78a06..b193eee 100644 --- a/superpage/src/pages/_components/BuyButton.astro +++ b/superpage/src/pages/_components/BuyButton.astro @@ -69,18 +69,21 @@ const currency = new Intl.NumberFormat("pt-BR", { target.disabled = true; + window.dataLayer?.push({ ecommerce: null }); // Clear the previous ecommerce object. window.dataLayer?.push({ event: "add_to_cart", - currency: "BRL", - value: parseFloat(unit_price), - items: [ - { - item_id: id, - item_name: name, - price: parseFloat(unit_price), - quantity: 1, - }, - ], + ecommerce: { + currency: "BRL", + value: parseFloat(unit_price), + items: [ + { + item_id: id, + item_name: name, + price: parseFloat(unit_price), + quantity: 1, + }, + ], + }, }); const r = await checkout(item);