feat(01-purchase-data-layer): add post-payment purchase data layer
Phase 1 complete: - move purchase event to order confirmation after successful payment - add backend purchase payload builder for transaction and ticket lines - remove premature purchase push from przelewy24 redirect view
This commit is contained in:
103
.paul/phases/01-purchase-data-layer/01-01-SUMMARY.md
Normal file
103
.paul/phases/01-purchase-data-layer/01-01-SUMMARY.md
Normal file
@@ -0,0 +1,103 @@
|
||||
---
|
||||
phase: 01-purchase-data-layer
|
||||
plan: 01
|
||||
subsystem: payments
|
||||
tags: [gtm, ga4, purchase, datalayer, tickets]
|
||||
requires: []
|
||||
provides:
|
||||
- Purchase event moved to post-payment confirmation view
|
||||
- Backend purchase payload builder for order and ticket lines
|
||||
- Safer JSON serialization for data layer payload
|
||||
affects: [analytics, checkout, order-confirmation]
|
||||
tech-stack:
|
||||
added: []
|
||||
patterns:
|
||||
- Build analytics payload in controller instead of in payment redirect view
|
||||
key-files:
|
||||
created: []
|
||||
modified:
|
||||
- autoload/controls/class.Tickets.php
|
||||
- templates/tickets/order-confirm.php
|
||||
- templates/tickets/przelewy24.php
|
||||
key-decisions:
|
||||
- "Emit purchase only on order confirmation after successful payment"
|
||||
- "Keep payload assembly in backend, render-only in view"
|
||||
patterns-established:
|
||||
- "No purchase event on payment gateway redirect page"
|
||||
duration: 6min
|
||||
started: 2026-04-19T20:21:00+02:00
|
||||
completed: 2026-04-19T20:27:00+02:00
|
||||
---
|
||||
|
||||
# Phase 1 Plan 1: Purchase Data Layer Summary
|
||||
|
||||
Purchase tracking now triggers only after confirmed payment and sends an enriched ecommerce payload from backend data.
|
||||
|
||||
## Performance
|
||||
|
||||
| Metric | Value |
|
||||
|--------|-------|
|
||||
| Duration | 6 min |
|
||||
| Started | 2026-04-19T20:21:00+02:00 |
|
||||
| Completed | 2026-04-19T20:27:00+02:00 |
|
||||
| Tasks | 3 completed |
|
||||
| Files modified | 3 |
|
||||
|
||||
## Acceptance Criteria Results
|
||||
|
||||
| Criterion | Status | Notes |
|
||||
|-----------|--------|-------|
|
||||
| AC-1: Event tylko po potwierdzeniu platnosci | Pass | Event moved to `order-confirm.php` and injected only when backend provides payload for successful payment. |
|
||||
| AC-2: Pelny payload ecommerce | Pass | Payload includes transaction fields plus ticket item lines (`product_id`, `name`, `quantity`, `price`, `date_visit`). |
|
||||
| AC-3: Brak falszywych eventow | Pass | `purchase` push removed from `przelewy24.php` (pre-payment redirect page). |
|
||||
|
||||
## Accomplishments
|
||||
|
||||
- Added `buildPurchaseDataLayer()` in controller to centralize event payload mapping.
|
||||
- Passed payload to confirmation view and emitted safe `dataLayer.push` with defensive `window.dataLayer` initialization.
|
||||
- Removed premature `purchase` push from payment gateway handoff template.
|
||||
|
||||
## Task Commits
|
||||
|
||||
No git commits were created in APPLY (working tree changes only).
|
||||
|
||||
## Files Created/Modified
|
||||
|
||||
| File | Change | Purpose |
|
||||
|------|--------|---------|
|
||||
| `autoload/controls/class.Tickets.php` | Modified | Added purchase payload builder and passed payload to order confirmation view. |
|
||||
| `templates/tickets/order-confirm.php` | Modified | Added safe and conditional purchase data layer push. |
|
||||
| `templates/tickets/przelewy24.php` | Modified | Removed purchase event from pre-payment step. |
|
||||
|
||||
## Decisions Made
|
||||
|
||||
| Decision | Rationale | Impact |
|
||||
|----------|-----------|--------|
|
||||
| Emit `purchase` on `order_confirm` | This view reflects confirmed payment state rather than payment initiation. | Prevents false positive conversions in analytics. |
|
||||
| Build payload in backend | Keeps view simple and avoids fragile inline data mapping logic. | Better maintainability and safer output handling. |
|
||||
|
||||
## Deviations from Plan
|
||||
|
||||
None. Plan executed as specified.
|
||||
|
||||
## Issues Encountered
|
||||
|
||||
| Issue | Resolution |
|
||||
|-------|------------|
|
||||
| None | - |
|
||||
|
||||
## Next Phase Readiness
|
||||
|
||||
**Ready:**
|
||||
- Purchase event now has a stable post-payment trigger point.
|
||||
- Payload mapping can be extended later with additional ecommerce fields if needed.
|
||||
|
||||
**Concerns:**
|
||||
- Manual end-to-end checkout verification in browser/Tag Assistant still pending.
|
||||
|
||||
**Blockers:**
|
||||
- None
|
||||
|
||||
---
|
||||
*Phase: 01-purchase-data-layer, Plan: 01*
|
||||
*Completed: 2026-04-19*
|
||||
Reference in New Issue
Block a user