fix: Poprawki dataLayer GA4 — purchase price, format kluczy, fałszywa konwersja GADS

- purchase: id→item_id (string), name→item_name, price fallback na price_brutto gdy brak promo, user_data poza ecommerce
- begin_checkout: id→item_id, name→item_name, dodano google_business_vertical
- Usunięto fałszywą konwersję GADS (gtag conversion) ze strony checkout
- view_item: dodano currency PLN, price jako number zamiast string
- Dodano event view_cart na stronie koszyka
- add_to_cart: quantity parseInt zamiast string

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-25 18:41:19 +01:00
parent 9c2932dad1
commit 6a2bfeb4db
4 changed files with 52 additions and 25 deletions

View File

@@ -170,25 +170,27 @@
currency: "PLN",
value: <?= \Shared\Helpers\Helpers::normalize_decimal( round( $this -> order['summary'], 2 ) ) - str_replace( ',', '.', round( $this -> order['transport_cost'], 2 ) );?>,
shipping: <?= \Shared\Helpers\Helpers::normalize_decimal( $this -> order['transport_cost'] );?>,
user_email: "<?= $this -> order['client_email'] ?>",
user_phone: "<?= $this -> order['client_phone'] ?>",
user_name: "<?= $this -> order['client_name'] ?>",
user_surname: "<?= $this -> order['client_surname'] ?>",
user_street: "<?= $this -> order['client_street'] ?>",
user_city: "<?= $this -> order['client_city'] ?>",
user_country: "Polska",
user_postal_code: "<?= $this -> order['client_postal_code'] ?>",
items: [
<? foreach ( $this -> order['products'] as $product ):?>
{
id: <?= (int)$product['product_id'];?>,
name: '<?= $product['name'];?>',
quantity: <?= $product['quantity'];?>,
price: <?= $product['price_brutto_promo'];?>,
item_id: "<?= $product['product_id'];?>",
item_name: '<?= $product['name'];?>',
quantity: <?= (int)$product['quantity'];?>,
price: <?= (float)$product['price_brutto_promo'] > 0 ? \Shared\Helpers\Helpers::normalize_decimal( $product['price_brutto_promo'] ) : \Shared\Helpers\Helpers::normalize_decimal( $product['price_brutto'] );?>,
google_business_vertical: 'retail'
}<? if ( $product != end( $this -> order['products'] ) ) echo ',';?>
<? endforeach;?>
]
},
user_data: {
email: "<?= $this -> order['client_email'] ?>",
phone_number: "<?= $this -> order['client_phone'] ?>",
first_name: "<?= $this -> order['client_name'] ?>",
last_name: "<?= $this -> order['client_surname'] ?>",
street: "<?= $this -> order['client_street'] ?>",
city: "<?= $this -> order['client_city'] ?>",
country: "PL",
postal_code: "<?= $this -> order['client_postal_code'] ?>"
}
});
<? endif;?>