Back to Guides
    integrationsintermediate30 minutesDec 25, 2024

    GA4 Event Tracking Configuration Guide

    Configure custom event tracking in GA4 to unlock AI-powered insights. Track conversions, engagement, and funnel steps that matter to your business.

    GA4 Event Tracking Configuration Guide

    TL;DR

    Configure custom GA4 events to track business-critical actions (trials, purchases, engagement) that unlock AI-powered optimization insights you'd never spot manually.

    What you'll accomplish:

    • Identify critical events that lead to revenue and predict churn
    • Implement custom event tracking via GTM, gtag.js, or server-side methods
    • Configure event parameters for rich analysis (value, product, category, user_id)
    • Test and validate events fire correctly across devices and scenarios
    • Enable AI analysis on custom events through BigQuery export

    Time required: 30 minutes | Difficulty: Intermediate | Prerequisites: GA4 property installed, website/app access, basic JavaScript or GTM knowledge

    Quick Start: List your 5 most important conversion and engagement actions → Implement as custom GA4 events → Verify in DebugView → Export to BigQuery for AI analysis.


    Related Resources

    Essential guides for getting the most from custom event tracking:


    Question

    How do I set up custom event tracking in GA4 to get better AI insights in Cogny?

    Answer

    Configure custom events in GA4 to track business-critical actions. Push these events through your website or app. Connect GA4 to BigQuery and Cogny.

    AI analyzes your custom events to find optimization opportunities you'd never spot manually.

    Quick Tip: Start with e-commerce events (purchase, add_to_cart) as they provide immediate ROI insights. These predefined events give Meta and Google's algorithms the clearest signals for campaign optimization.

    Why Custom Events Matter

    GA4's automatic events are useful. Page views, scrolls, clicks.

    But they don't track YOUR business logic:

    • Free trial signups
    • Feature usage
    • Checkout steps
    • Upgrade conversions
    • Churn signals

    Without custom events, AI can't optimize what matters to your revenue.

    What You'll Track

    After this guide:

    Conversion events Exact actions that lead to revenue (trial starts, purchases, upgrades)

    Engagement events User behaviors that indicate interest (video views, tool usage, downloads)

    Funnel events Steps in your conversion path (cart adds, checkout starts, payment info)

    Retention events Signals of long-term value (repeat purchases, feature adoption, referrals)


    Step 1: Identify Critical Events

    Before touching code, define what matters.

    Ask these questions:

    1. What actions lead to revenue?
    2. What behaviors predict churn?
    3. What features drive retention?
    4. What content converts visitors?

    Example for SaaS:

    • trial_start - User begins free trial
    • feature_used_* - Usage of key features
    • upgrade_initiated - User clicks upgrade button
    • payment_completed - Subscription payment processed
    • invite_sent - User invites team member

    Example for E-commerce:

    • product_viewed - Product page view
    • add_to_cart - Item added to cart
    • checkout_started - User enters checkout flow
    • payment_info_added - Payment details entered
    • purchase - Order completed

    Time: 10 minutes (critical planning step)


    Note: Custom events require GA4 BigQuery export for full AI analysis—set this up first in our GA4 Integration guide. Without BigQuery, you'll only see basic reports in the GA4 interface.

    Step 2: Configure Events in GA4

    Log into analytics.google.com

    Select your GA4 property.

    Click ConfigureEvents

    Click Create Event

    Two options:

    1. Modify existing events (simple transformations)
    2. Create from scratch (custom tracking)

    For custom business events, you'll implement tracking in code (Step 3). For now, understand GA4's event structure.

    Time: 5 minutes


    Step 3: Implement Event Tracking

    Option A: Google Tag Manager (Recommended)

    Easier to manage. No code deployments needed. Marketing team can make changes.

    Option B: Direct gtag.js Implementation

    More control. Works if you don't use GTM. Requires code changes.

    Option C: Server-Side Measurement Protocol

    Most reliable. Bypasses ad blockers. Best for critical events (purchases, signups).

    Let's cover all three.

    Time: Varies by method


    Method 1: Google Tag Manager Setup

    Step 3A: Create Data Layer Variables

    Go to tagmanager.google.com

    Select your container.

    Click VariablesNew

    Create variables for event data:

    Example variable: User ID

    • Variable Type: Data Layer Variable
    • Data Layer Variable Name: userId
    • Save as: DL - User ID

    Example variable: Plan Type

    • Variable Type: Data Layer Variable
    • Data Layer Variable Name: planType
    • Save as: DL - Plan Type

    Time: 5 minutes


    Step 3B: Create GA4 Event Tag

    Click TagsNew

    Tag Configuration: Google Analytics: GA4 Event

    Configuration:

    • Measurement ID: Your GA4 Measurement ID (G-XXXXXXXXXX)
    • Event Name: trial_start (example)

    Add Event Parameters:

    Click Event ParametersAdd Row

    Parameter examples:

    • user_id: {{DL - User ID}}
    • plan_type: {{DL - Plan Type}}
    • trial_duration: {{DL - Trial Duration}}

    Time: 5 minutes per event


    Step 3C: Create Trigger

    Triggering:

    • Trigger Type: Custom Event
    • Event name: trial_start

    This fires when your website pushes this event to dataLayer.

    Save the tag.

    Time: 2 minutes


    Step 3D: Implement DataLayer Push in Code

    In your application code, push events to dataLayer:

    // When user starts trial
    window.dataLayer = window.dataLayer || [];
    window.dataLayer.push({
      event: 'trial_start',
      userId: user.id,
      planType: 'pro',
      trialDuration: 14
    });
    
    // When user completes purchase
    window.dataLayer.push({
      event: 'purchase',
      transactionId: order.id,
      value: order.total,
      currency: 'USD',
      items: [{
        item_id: product.id,
        item_name: product.name,
        price: product.price,
        quantity: 1
      }]
    });
    

    Time: 10 minutes per event (varies by complexity)


    Method 2: Direct gtag.js Implementation

    If you're not using GTM, implement directly:

    Add gtag.js to your site:

    <!-- In your <head> -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());
      gtag('config', 'G-XXXXXXXXXX');
    </script>
    

    Track custom events:

    // Trial start event
    gtag('event', 'trial_start', {
      user_id: user.id,
      plan_type: 'pro',
      trial_duration: 14
    });
    
    // Feature usage event
    gtag('event', 'feature_used', {
      feature_name: 'export_report',
      user_id: user.id,
      account_age_days: 7
    });
    
    // Upgrade event
    gtag('event', 'upgrade_completed', {
      user_id: user.id,
      from_plan: 'free',
      to_plan: 'pro',
      value: 99.00,
      currency: 'USD'
    });
    

    Time: 5-10 minutes per event


    Method 3: Server-Side Tracking

    Most reliable for critical events. Bypasses browser-based blockers.

    Step 3E: Use Measurement Protocol

    Send events from your backend:

    # Python example
    import requests
    
    def send_ga4_event(measurement_id, api_secret, client_id, event_name, params):
        url = f"https://www.google-analytics.com/mp/collect?measurement_id={measurement_id}&api_secret={api_secret}"
    
        payload = {
            "client_id": client_id,
            "events": [{
                "name": event_name,
                "params": params
            }]
        }
    
        response = requests.post(url, json=payload)
        return response
    
    # Usage
    send_ga4_event(
        measurement_id="G-XXXXXXXXXX",
        api_secret="YOUR_API_SECRET",
        client_id=user.id,
        event_name="trial_start",
        params={
            "plan_type": "pro",
            "trial_duration": 14,
            "value": 0
        }
    )
    
    // Node.js example
    const axios = require('axios');
    
    async function sendGA4Event(measurementId, apiSecret, clientId, eventName, params) {
      const url = `https://www.google-analytics.com/mp/collect?measurement_id=${measurementId}&api_secret=${apiSecret}`;
    
      const payload = {
        client_id: clientId,
        events: [{
          name: eventName,
          params: params
        }]
      };
    
      await axios.post(url, payload);
    }
    
    // Usage
    await sendGA4Event(
      'G-XXXXXXXXXX',
      'YOUR_API_SECRET',
      user.id,
      'purchase',
      {
        transaction_id: order.id,
        value: order.total,
        currency: 'USD',
        items: order.items
      }
    );
    

    Get API Secret: GA4 → Admin → Data Streams → [Your Stream] → Measurement Protocol API secrets

    Time: 15 minutes initial setup, 5 minutes per event


    Step 4: Mark Events as Conversions

    Not all events are conversions. But revenue-driving events should be.

    In GA4:

    Click ConfigureEvents

    Find your event in the list.

    Toggle Mark as conversion to ON.

    Examples to mark as conversions:

    • trial_start
    • purchase
    • upgrade_completed
    • qualified_lead

    Do NOT mark these as conversions:

    • page_view
    • scroll
    • file_download (unless directly revenue-related)

    Why this matters: Conversions train Google's AI. They also help Cogny identify high-value user paths.

    Time: 2 minutes


    Step 5: Verify Events Are Firing

    Use DebugView:

    In GA4: ConfigureDebugView

    On your website, enable debug mode:

    gtag('config', 'G-XXXXXXXXXX', {
      debug_mode: true
    });
    

    Or add ?gtm_debug=true to URL if using GTM.

    Perform the action (e.g., start trial).

    Watch DebugView for your event.

    You should see:

    • Event name
    • All parameters
    • User properties
    • Timestamp

    If it appears: You're good. If it doesn't: Check console for errors, verify GTM triggers, check dataLayer pushes.

    Time: 5 minutes


    Step 6: Wait for BigQuery Export

    Events appear in BigQuery the next day (if you have daily export enabled).

    See our GA4 Integration Guide for BigQuery setup. For faster iteration on event tracking without code deployments, consider using Google Tag Manager.

    After 24 hours:

    Go to console.cloud.google.com/bigquery

    Query your events:

    SELECT
      event_name,
      COUNT(*) as event_count,
      COUNT(DISTINCT user_pseudo_id) as unique_users
    FROM `project.analytics_XXXXXX.events_*`
    WHERE _TABLE_SUFFIX = FORMAT_DATE('%Y%m%d', CURRENT_DATE())
      AND event_name = 'trial_start'
    GROUP BY event_name
    

    You should see your custom events.

    Time: 5 minutes (next day)


    Step 7: Connect to Cogny

    If you haven't already, connect BigQuery to Cogny.

    See BigQuery Connection Guide.

    Cogny automatically:

    1. Discovers your custom events
    2. Analyzes patterns across events
    3. Identifies conversion paths
    4. Generates optimization recommendations

    Time: Already done if BigQuery is connected


    Best Practices for Event Naming

    Use verb_noun structure:

    • trial_start
    • video_complete
    • feature_enable
    • trialstarted
    • video

    Be specific but consistent:

    • checkout_step_1_shipping
    • checkout_step_2_payment
    • checkout_step_3_review
    • checkout (too vague)

    Use lowercase with underscores:

    • add_to_cart
    • AddToCart
    • add-to-cart

    Match GA4's recommended events when possible:

    GA4 has predefined events for e-commerce:

    • view_item
    • add_to_cart
    • begin_checkout
    • purchase

    Use these exact names for standard actions. AI gets better training data.


    Example: Complete E-commerce Tracking

    Product page view:

    gtag('event', 'view_item', {
      currency: 'USD',
      value: 99.00,
      items: [{
        item_id: 'SKU_12345',
        item_name: 'Wireless Headphones',
        item_category: 'Electronics',
        item_variant: 'Black',
        price: 99.00,
        quantity: 1
      }]
    });
    

    Add to cart:

    gtag('event', 'add_to_cart', {
      currency: 'USD',
      value: 99.00,
      items: [{
        item_id: 'SKU_12345',
        item_name: 'Wireless Headphones',
        item_category: 'Electronics',
        item_variant: 'Black',
        price: 99.00,
        quantity: 1
      }]
    });
    

    Begin checkout:

    gtag('event', 'begin_checkout', {
      currency: 'USD',
      value: 99.00,
      items: [{
        item_id: 'SKU_12345',
        item_name: 'Wireless Headphones',
        item_category: 'Electronics',
        item_variant: 'Black',
        price: 99.00,
        quantity: 1
      }]
    });
    

    Purchase:

    gtag('event', 'purchase', {
      transaction_id: 'T_12345',
      value: 99.00,
      tax: 8.00,
      shipping: 5.00,
      currency: 'USD',
      items: [{
        item_id: 'SKU_12345',
        item_name: 'Wireless Headphones',
        item_category: 'Electronics',
        item_variant: 'Black',
        price: 99.00,
        quantity: 1
      }]
    });
    

    Why this structure matters: Cogny's AI can now analyze:

    • Product view → cart conversion rate
    • Cart → checkout conversion rate
    • Checkout → purchase conversion rate
    • Where users drop off
    • Which products drive highest completion rates

    Example: SaaS Onboarding Tracking

    User signs up:

    gtag('event', 'sign_up', {
      method: 'google'
    });
    

    User completes onboarding step:

    gtag('event', 'onboarding_step_complete', {
      step_name: 'connect_data_source',
      step_number: 2
    });
    

    User invites team member:

    gtag('event', 'invite_sent', {
      recipient_count: 1
    });
    

    User upgrades:

    gtag('event', 'upgrade_completed', {
      from_plan: 'free',
      to_plan: 'pro',
      value: 99.00,
      currency: 'USD'
    });
    

    AI insight this enables: "Users who complete onboarding step 2 within 24 hours have 3.4x higher upgrade rate → Send reminder email at 18 hours → Expected conversion lift: 28%"


    What Cogny Does With Events

    Once events are in BigQuery:

    1. Path Analysis

    AI identifies sequences that predict conversion:

    "Users who: view_demo → sign_up → onboarding_step_2 → invite_sent have 89% upgrade rate within 14 days"

    Recommendation: Optimize demo content, improve onboarding step 2, encourage invites.

    2. Drop-off Detection

    "47% of users who add_to_cart never reach begin_checkout → Likely issue: unexpected shipping costs or account creation requirement"

    Recommendation: Show shipping costs earlier, enable guest checkout.

    3. Cohort Comparison

    "Users from organic search who watch_demo_video have 2.1x higher LTV than users who skip video"

    Recommendation: Add video CTA on organic landing pages.

    4. Predictive Modeling

    "Users who complete these 3 actions in first 7 days have 94% probability of remaining active at 90 days:

    • feature_used_export
    • invite_sent
    • report_created"

    Recommendation: Drive these behaviors in onboarding.


    Common Issues

    "Events not appearing in GA4"

    Check:

    1. Debug mode enabled? Use DebugView.
    2. GTM tag firing? Use GTM Preview mode.
    3. Correct Measurement ID? Double-check G-XXXXXXXXXX.
    4. Ad blocker active? Test in incognito with extensions disabled.

    "Events in GA4 but not BigQuery"

    BigQuery export is delayed 24-48 hours for first export. After that, daily exports complete around 9 AM.

    Check BigQuery export is enabled: GA4 → Admin → BigQuery Links → Verify status is "Active"

    "Events have missing parameters"

    Parameters not passed correctly.

    Check your dataLayer push or gtag call:

    // Wrong - parameters as separate arguments
    gtag('event', 'trial_start', 'plan_type', 'pro');
    
    // Right - parameters as object
    gtag('event', 'trial_start', {
      plan_type: 'pro'
    });
    

    "Too many unique event names"

    GA4 limits: 500 unique event names per property.

    If you hit this:

    • Consolidate similar events
    • Use event parameters instead of unique names

    Example:

    • feature_export_used, feature_share_used, feature_schedule_used
    • feature_used with parameter feature_name

    "Events firing multiple times"

    Common with SPAs (Single Page Apps).

    Check:

    1. GTM tag firing on every page change?
    2. React/Vue component mounting multiple times?
    3. Event listener added multiple times?

    Solution: Use GTM's "Once per event" trigger setting or debounce event calls.


    Pro Tips

    1. Send user_id for logged-in users

    gtag('config', 'G-XXXXXXXXXX', {
      user_id: 'USER_12345'
    });
    

    This enables cross-device tracking and better LTV analysis.

    2. Use enhanced e-commerce for accurate revenue attribution

    Don't just track purchase. Track the full funnel: view → add_to_cart → begin_checkout → add_payment_info → purchase

    This gives Cogny context for optimization.

    3. Track engagement with value

    Even non-revenue events can have value:

    gtag('event', 'video_complete', {
      video_title: 'Product Demo',
      value: 10 // Engagement value
    });
    

    This helps AI understand which content drives conversions.

    4. Use event parameters for segmentation

    gtag('event', 'trial_start', {
      plan_type: 'pro',
      trial_duration: 14,
      traffic_source: 'google_ads',
      landing_page: '/pricing'
    });
    

    More context = better AI insights.

    5. Implement error tracking

    // Track errors as events
    window.addEventListener('error', (event) => {
      gtag('event', 'exception', {
        description: event.message,
        fatal: false
      });
    });
    

    Helps identify technical issues affecting conversions.

    6. Track negative events

    Not just successes:

    gtag('event', 'checkout_abandoned', {
      cart_value: 127.00,
      step: 'payment_info'
    });
    
    gtag('event', 'upgrade_declined', {
      reason: 'price_too_high'
    });
    

    AI identifies patterns in failures too.


    What You Can Do Now

    Immediate actions:

    1. Audit current tracking

      • Review existing events in GA4
      • Identify gaps in funnel coverage
      • Plan new events to fill gaps
    2. Implement critical conversion events

      • Trial starts
      • Purchases
      • Upgrades
      • Qualified leads
    3. Set up funnel tracking

      • Every step from landing to conversion
      • Enable drop-off analysis
      • Support AI path optimization
    4. Verify data quality

      • Use DebugView to test
      • Check BigQuery export
      • Validate parameters are captured

    Next Steps

    Immediate actions:

    • Configure your top 5 conversion events (trial_start, purchase, etc.)
    • Verify events in GA4 DebugView before going live

    Advanced implementation:

    Need help? Contact support


    FAQ

    Q: How many events should I track?

    Start with 5-10 critical business events. Add more as you identify patterns.

    Too few: Not enough insight. Too many: Noisy data, hard to analyze.

    Q: Should I use GA4's automatic events or custom events?

    Both.

    Automatic events (page_view, scroll, click) provide baseline data. Custom events track your specific business logic.

    Q: Can I change event names later?

    Yes, but it breaks historical comparisons.

    Better: Create new event, track both for a transition period, then deprecate old one.

    Q: What's the difference between events and conversions?

    All conversions are events. Not all events are conversions.

    Events: Any trackable action. Conversions: Events that drive business value (mark these in GA4).

    Q: How long until Cogny's AI uses my events?

    • Event data in BigQuery: 24-48 hours (first export)
    • Cogny discovers events: Immediately after sync
    • First insights: 2-3 days (needs pattern data)
    • Full optimization: 1-2 weeks (needs sufficient volume)

    Q: Can I track events without GA4?

    Yes.

    You can send custom events directly to BigQuery from your backend. Cogny analyzes any event data in your warehouse.

    But GA4 provides useful context (device, location, traffic source) that enriches analysis.

    Q: What if my events have different names across platforms?

    Cogny can map equivalent events:

    • trial_start (GA4)
    • trial_signup (backend)
    • free_trial_begin (CRM)

    Ask Cogny's AI to create mapping rules.


    Ready to Get Better AI Insights?

    Most teams track page views and purchases. That's it.

    But the magic happens between those two events.

    Every click, every scroll, every micro-conversion is a signal. AI needs these signals to optimize your funnel.

    Not tracking custom events yet?

    Schedule a demo and we'll help you identify the 10 events that will unlock the best AI insights for your business.


    About This Guide

    Written by the Cogny team—built by the founders who created AI optimization systems for Netflix, Zalando, and Momondo at Campanja, and scaled growth for Kry, Epidemic Sound, and Yubico through GrowthHackers.se.

    We've implemented event tracking for hundreds of businesses. This is the proven framework.

    Last Updated: December 25, 2024

    Ready to Get Started?

    See Cogny in Action

    Schedule a demo to see how AI can transform your marketing analytics and automate your growth optimization.

    Schedule Demo