All Guides
Analytics + Measurement

Set Up Advanced GA4

Add custom event tracking, e-commerce data, and advanced features to GA4.

What this covers: Custom event tracking with gtag.js, e-commerce event implementation for WooCommerce and Shopify, user properties for audience segmentation, and conversion marking in GA4.

Who it’s for: Technical marketers or developers with basic GA4 already running who need deeper tracking beyond Enhanced Measurement.

Key outcome: You’ll have custom events firing for button clicks, form submissions, and phone taps, plus e-commerce purchase data flowing into GA4 reports.

Time to read: 6 minutes

Part of: Analytics & Measurement series

🔧 Skill Level: Technical marketing or developer

This guide involves custom JavaScript. If you’re not comfortable with code, use a plugin like MonsterInsights Pro (WordPress) or ask your developer to implement these patterns.

This guide covers: Custom event tracking, e-commerce implementation, and user properties. Assumes basic GA4 is already set up.

Do You Need Advanced GA4?

Basic GA4 (with Enhanced Measurement) covers most small business needs. You need this guide if:

  • E-commerce site: You want purchase data, product views, and cart abandonment in GA4
  • Custom interactions: You need to track actions GA4 doesn’t capture automatically
  • Lead generation: You want to track form submissions with form names and field data
  • Content business: You need video engagement, scroll depth, or time-on-page data

If basic page views and standard events are enough, stick with the Basic GA4 Setup.

Custom Event Tracking

GA4 events follow this pattern:

gtag('event', 'event_name', {
  parameter_1: 'value',
  parameter_2: 'value'
});

Example: Track Button Clicks

Where this goes: Just before </body> or in your JavaScript bundle.

// Track CTA button clicks
document.querySelectorAll('.cta-button').forEach(button => {
  button.addEventListener('click', () => {
    gtag('event', 'cta_click', {
      button_text: button.textContent,
      button_location: window.location.pathname
    });
  });
});

Example: Track Form Submissions

// Track contact form submissions
document.querySelector('#contact-form').addEventListener('submit', () => {
  gtag('event', 'form_submit', {
    form_name: 'contact',
    page_location: window.location.pathname
  });
});

Example: Track Phone Number Clicks

// Track phone link clicks
document.querySelectorAll('a[href^="tel:"]').forEach(link => {
  link.addEventListener('click', () => {
    gtag('event', 'phone_click', {
      phone_number: link.href.replace('tel:', '')
    });
  });
});

E-Commerce Tracking

GA4 has built-in e-commerce events. Use these exact event names for data to appear in e-commerce reports.

WordPress + WooCommerce

Plugin method (recommended): MonsterInsights Pro or WooCommerce Google Analytics Integration handles this automatically.

Shopify

Basic e-commerce tracking works automatically when you add your Measurement ID. For enhanced tracking, use the Google & YouTube app.

Custom Implementation

If you need manual control, here are the key events:

Product View

// When user views a product page
gtag('event', 'view_item', {
  currency: 'USD',
  value: 29.99,
  items: [{
    item_id: 'SKU_12345',
    item_name: 'Product Name',
    price: 29.99
  }]
});

Add to Cart

// When user adds item to cart
gtag('event', 'add_to_cart', {
  currency: 'USD',
  value: 29.99,
  items: [{
    item_id: 'SKU_12345',
    item_name: 'Product Name',
    price: 29.99,
    quantity: 1
  }]
});

Purchase

// After successful checkout
gtag('event', 'purchase', {
  transaction_id: 'T_12345',
  currency: 'USD',
  value: 59.98,
  items: [
    { item_id: 'SKU_12345', item_name: 'Product 1', price: 29.99, quantity: 1 },
    { item_id: 'SKU_67890', item_name: 'Product 2', price: 29.99, quantity: 1 }
  ]
});

User Properties

User properties let you segment reports by custom attributes (member status, customer tier, etc.).

// Set user properties
gtag('set', 'user_properties', {
  customer_tier: 'premium',
  membership_status: 'active'
});

These appear in GA4 under Configure → User properties after data starts flowing.

Mark Events as Conversions

After your custom events start appearing in GA4:

  1. Go to Admin → Events
  2. Find your custom event (may take 24 hours to appear)
  3. Toggle Mark as conversion

This makes the event appear in conversion reports and lets you import it to Google Ads.

Sources

Advanced GA4 Questions Answered

What is the difference between GA4 and Universal Analytics?

GA4 uses an event-based data model where every interaction is an event, replacing Universal Analytics’ session-based hit model. GA4 also introduces predictive metrics, cross-platform tracking, and BigQuery integration at no additional cost.

How long does GA4 retain user data?

GA4 retains event-level data for either 2 months or 14 months, configurable in Admin > Data Settings > Data Retention. Aggregated reports are not affected by this retention window.

What are GA4 custom dimensions and when should you use them?

Custom dimensions let you attach metadata to events, like content category, author, or membership tier. Use them when GA4’s built-in parameters don’t capture business-specific attributes you need for segmentation and reporting.

How do you set up cross-domain tracking in GA4?

Configure cross-domain tracking in Admin > Data Streams > Configure Tag Settings > Configure Your Domains. Add each domain you want linked so GA4 passes the client ID across domains and unifies user sessions.

✓ Confirming Your Advanced GA4 Setup

  • Your custom events appear in GA4 → Reports → Engagement → Events
  • E-commerce data shows in GA4 → Reports → Monetization (if applicable)
  • Key events are marked as conversions

Testing tip: Use GA4 DebugView (Configure → DebugView) to see events in real-time while testing.

Debugging Custom Events

If events aren’t appearing:

  1. Enable DebugView: Add ?debug_mode=true to your URL or set gtag('config', 'G-XXXXX', { debug_mode: true })
  2. Check Console: Open browser DevTools → Console and look for gtag errors
  3. Verify gtag loaded: Type gtag in Console—it should return the function, not “undefined”
  4. Check event names: GA4 event names are case-sensitive and can’t contain spaces