Files
shopPRO/.paul/phases/11-datalayer-ga4-fix/11-01-SUMMARY.md
Jacek 589f9d9a38 feat: DataLayer GA4 analytics fix — poprawka eventów ecommerce
Naprawione eventy purchase, begin_checkout, view_item, add_to_cart
do formatu GA4 (item_id/item_name zamiast id/name, currency PLN,
google_business_vertical, poprawne typy danych).
Dodany nowy event view_cart na stronie koszyka.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 19:01:22 +01:00

4.1 KiB

phase, plan, subsystem, tags, requires, provides, affects, tech-stack, key-files, key-decisions, patterns-established, duration, completed
phase plan subsystem tags requires provides affects tech-stack key-files key-decisions patterns-established duration completed
11-datalayer-ga4-fix 01 frontend
datalayer
ga4
gtm
ecommerce
analytics
remarketing
phase provides
none n/a
GA4-compliant dataLayer events (purchase, begin_checkout, view_item, add_to_cart, view_cart)
google_business_vertical for dynamic remarketing
added patterns
GA4 ecommerce item format with item_id/item_name/google_business_vertical
created modified
templates/shop-order/order-details.php
templates/shop-basket/summary-view.php
templates/shop-product/product.php
templates/shop-basket/basket.php
view_cart event in basket.php (not basket-details.php) — basket-details is AJAX-replaceable
No user_data in purchase — requires RODO analysis, deferred
GA4 item format: item_id (string), item_name, price (number), quantity (number), google_business_vertical: retail
All ecommerce events must include currency: PLN
15min 2026-03-25

Phase 11 Plan 01: DataLayer GA4 Analytics Fix Summary

Naprawione 5 eventow dataLayer ecommerce do formatu GA4 — remarketing dynamiczny i konwersje teraz dzialaja poprawnie.

Performance

Metric Value
Duration ~15min
Completed 2026-03-25
Tasks 2 completed
Files modified 4

Acceptance Criteria Results

Criterion Status Notes
AC-1: Purchase event — format GA4 z prawidlowa cena Pass item_id (string), item_name, price via normalize_decimal, google_business_vertical, usuniety hardcoded value: 25.42
AC-2: Begin_checkout event — format GA4 Pass id→item_id, name→item_name, dodany google_business_vertical
AC-3: View_item event — kompletne dane Pass Dodane currency: PLN, value, price jako number, google_business_vertical
AC-4: Add_to_cart event — poprawne typy Pass Dodany google_business_vertical, parseInt(quantity)
AC-5: View_cart event — nowy event Pass Nowy event na /koszyk z pelnym zestawem danych GA4

Accomplishments

  • Naprawione klucze itemow we wszystkich eventach: id/name → item_id/item_name (format GA4)
  • Dodane brakujace pola: currency: PLN, value, google_business_vertical: retail
  • Usuniety hardcoded value: 25.42 z purchase event (debug artifact)
  • Dodany nowy event view_cart na stronie koszyka /koszyk
  • Poprawione typy danych: price jako number (nie string), quantity jako int

Files Created/Modified

File Change Purpose
templates/shop-order/order-details.php Modified Purchase event: item_id/item_name, fix price, remove hardcoded value, add google_business_vertical
templates/shop-basket/summary-view.php Modified Begin_checkout event: item_id/item_name, add google_business_vertical
templates/shop-product/product.php Modified View_item: add currency/value/google_business_vertical. Add_to_cart: add google_business_vertical, parseInt(quantity)
templates/shop-basket/basket.php Modified New view_cart event with full GA4 item data

Decisions Made

Decision Rationale Impact
view_cart w basket.php, nie basket-details.php basket-details jest AJAX-replaceable — script by sie odpalal przy kazdym AJAX reload Konsystentne z decyzja z fazy 10
Pominiecie user_data w purchase Wymaga analizy RODO/GDPR przed wyslaniem PII do dataLayer Mozna dodac w przyszlosci po analizie
GADS conversion na checkout — nie znaleziono Grep nie znalazl hardcoded GADS conversion w szablonach — prawdopodobnie w GTM Nie trzeba usuwac z kodu

Deviations from Plan

None — plan executed exactly as written.

Issues Encountered

None.

Skill Audit

  • /feature-dev: not invoked (optional for template-only changes)
  • /koniec-pracy: pending (release workflow)

Next Phase Readiness

Ready:

  • Wszystkie eventy dataLayer zgodne z GA4
  • Gotowe do weryfikacji w GTM Preview / GA4 DebugView na produkcji

Concerns:

  • None

Blockers:

  • None

Phase: 11-datalayer-ga4-fix, Plan: 01 Completed: 2026-03-25