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