Skip to content

Conversation

@dzienisz
Copy link
Member

@dzienisz dzienisz commented Jan 23, 2026

Implement Google Analytics Tracking for Ticket Sales

📝 Summary

This PR integrates GA4 (Google Analytics 4) ecommerce tracking to measure the conversion funnel—from the initial intent of clicking "Buy" to the successful purchase confirmation on the thank-you page.

🚀 Key Changes

  • GA Utility Layer: Created src/utils/gtag.ts to provide a type-safe wrapper for the global gtag function. It includes safety checks to prevent errors during local development or if the GA script fails to load.
  • Checkout Intent Tracking: Added the begin_checkout event to the "Get your ticket!" buttons in the TicketVariant component. This allows us to track which ticket types (Regular vs. VIP) users are interested in.
  • Automated Purchase Tracking: Modified the ThankYou component to automatically trigger a purchase event. It extracts transaction details (Order ID, Product Name, Price, Currency, and Quantity) directly from the URL parameters provided by the checkout system.
  • Developer Experience: Added proper TypeScript declarations for window.gtag to resolve linting errors and ensure type safety across the tracking implementation.

📊 Analytics Events

Event Trigger Captured Data
begin_checkout Click on any "Get your ticket!" button item_name, price, currency
purchase Landing on the /thank-you page transaction_id, value, currency, items (name, price, qty)

🛠 Testing Instructions

  1. Checkout Intent: Open the site, open the console or Google Tag Assistant, and click "Get your ticket!". Verify the begin_checkout event fires.
  2. Purchase: Navigate to a simulated success URL (which is also supported by the route validator):
    /thank-you?ec_order_id=TEST_123&ec_product=VIP&ec_price=512&ec_currency=PLN&ec_amount=1&ec_product_id=1&ec_product_uuid=1&ec_price_id=1
  3. Confirm the purchase event appears in the GA4 Real-time dashboard with the correct values.

@dzienisz dzienisz requested a review from ssynowiec January 23, 2026 18:40
@dzienisz dzienisz self-assigned this Jan 23, 2026
@dzienisz dzienisz requested a review from naugtur January 23, 2026 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants