6 min read

How to Monitor User Acquisition in Google Analytics 4

GA4 handles acquisition tracking differently than Universal Analytics. Instead of a single source/medium field, GA4 auto-tracks session source, medium, and campaign from UTM parameters and traffic signals. But if you're not careful with how you structure UTM tags, send custom events, or query the data, you'll miss critical insights about where your users actually come from.

Set Up Acquisition Tracking with gtag.js

GA4 automatically tracks traffic sources using UTM parameters and browser signals. Here's how to ensure you're capturing acquisition events correctly.

Add gtag.js to your site

Install the GA4 measurement code on every page. GA4 will automatically send a session_start event that includes the traffic source (sessionSource), medium (sessionMedium), and campaign (sessionCampaign) derived from UTM parameters or referrer data.

javascript
<!-- Add this in the <head> of your HTML -->
<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>
Replace G-XXXXXXXXXX with your GA4 Measurement ID

Verify UTM parameters in your campaign links

GA4 extracts utm_source, utm_medium, utm_campaign, utm_content, and utm_term from URLs. These populate the sessionSource, sessionMedium, and sessionCampaign dimensions. Make sure your marketing links include consistent UTM tags—GA4 is case-sensitive, so utm_source=google and utm_source=Google are treated as different sources.

javascript
// Build a campaign URL with UTM parameters
const campaignUrl = new URL('https://example.com/pricing');
campaignUrl.searchParams.append('utm_source', 'newsletter');
campaignUrl.searchParams.append('utm_medium', 'email');
campaignUrl.searchParams.append('utm_campaign', 'q1_promo');
campaignUrl.searchParams.append('utm_content', 'cta_button');

console.log(campaignUrl.toString());
// https://example.com/pricing?utm_source=newsletter&utm_medium=email&utm_campaign=q1_promo&utm_content=cta_button
Use this pattern to construct trackable campaign URLs

Send custom acquisition events

If you want to track acquisition beyond standard traffic sources—like when a user signs up through a partner program or a custom referral link—send a custom event with gtag('event'). This supplements the automatic session_start event and helps you segment users by acquisition method.

javascript
// Track a sign-up via referral
gtag('event', 'sign_up', {
  'method': 'referral_program',
  'referral_source': 'partner_a'
});

// Track a purchase from a specific campaign
gtag('event', 'purchase', {
  'value': 99.99,
  'currency': 'USD',
  'campaign_id': 'spring_sale_2024'
});
Custom events let you track acquisition sources beyond UTM parameters
Watch out: GA4 only retains the first-click source. If a user arrives from email, then later visits via organic search, GA4 records them as acquired from email. Use the firstUserSource dimension if you specifically want the original acquisition channel.

Query Acquisition Metrics with the Google Analytics Data API

To analyze acquisition trends, compare sources, and monitor conversion funnels, use the Google Analytics Data API to pull structured reports.

Pull active users and new users by traffic source

Use the Google Analytics Data API to fetch acquisition metrics. This is the modern way to query GA4 data—much faster than the UI reports. Request activeUsers or newUsers metrics broken down by sessionSource to see which channels drive traffic.

javascript
const {BetaAnalyticsDataClient} = require('@google-analytics/data');
const client = new BetaAnalyticsDataClient();

async function getAcquisitionBySource(propertyId) {
  const [response] = await client.runReport({
    property: `properties/${propertyId}`,
    dateRanges: [{ startDate: '30daysAgo', endDate: 'today' }],
    metrics: [
      { name: 'activeUsers' },
      { name: 'newUsers' }
    ],
    dimensions: [
      { name: 'sessionSource' },
      { name: 'sessionMedium' }
    ]
  });
  return response.rows;
}

getAcquisitionBySource('YOUR_PROPERTY_ID').then(rows => console.log(rows));
Fetch acquisition metrics programmatically using the Data API

Segment by first-user source to track original acquisition

For new user cohorts, use firstUserSource instead of sessionSource—it shows where a user came from on their first session, not their current session. This is critical for understanding acquisition quality and lifetime value by channel.

javascript
const [response] = await client.runReport({
  property: `properties/${propertyId}`,
  dateRanges: [{ startDate: '90daysAgo', endDate: 'today' }],
  metrics: [
    { name: 'newUsers' },
    { name: 'totalPurchaseRevenue' }
  ],
  dimensions: [
    { name: 'firstUserSource' },
    { name: 'firstUserMedium' }
  ]
});

// Shows: "100 new users from Google (organic) generated $5,000 in revenue"
Use firstUserSource to measure value by original acquisition channel

Monitor conversion events from acquisition channels

Combine acquisition dimensions with conversion events to measure funnel performance. Filter for a specific purchase or sign_up event, then segment by firstUserSource. This shows which acquisition channels deliver the highest-quality users.

javascript
const [response] = await client.runReport({
  property: `properties/${propertyId}`,
  dateRanges: [{ startDate: '30daysAgo', endDate: 'today' }],
  metrics: [{ name: 'eventCount' }],
  dimensions: [
    { name: 'firstUserSource' },
    { name: 'eventName' }
  ],
  dimensionFilter: {
    filter: {
      fieldName: 'eventName',
      value: 'purchase'
    }
  }
});

// Results: "400 purchase events from email-acquired users, 150 from organic"
Measure conversion performance by original acquisition source
Tip: GA4's Data API has a 10-million-row limit per query. If you're analyzing a large property, filter by date range or specific dimensions to stay within limits. Remember that sessionSource is the *current* traffic source, not the acquisition source—use firstUserSource to track where users originally came from.

Monitor Acquisition in Real Time

Beyond daily reports, track real-time acquisition to spot trends and verify campaigns immediately.

Check real-time active users by source

In the Realtime report (available in the GA4 UI), navigate to Overview and watch Top traffic sources to see which channels drive active users right now. This is useful during a campaign launch to verify that your UTM parameters are working correctly.

javascript
const [response] = await client.runRealtimeReport({
  property: `properties/${propertyId}`,
  metrics: [{ name: 'activeUsers' }],
  dimensions: [{ name: 'sessionSource' }]
});

// Shows active users *right now* (1-2 minute lag) by source
response.rows.forEach(row => {
  console.log(`${row.dimensionValues[0].value}: ${row.metricValues[0].value} active`);
});
Query real-time acquisition data to spot campaign spikes instantly
Tip: Real-time reports have a 1-2 minute lag. Don't use them to verify event tracking in development—use DebugView in GA4's admin panel instead, which shows events with a few seconds latency.

Common Pitfalls

  • Confusing sessionSource (current session's source) with firstUserSource (original acquisition source). Use firstUserSource to measure where users were actually acquired and their lifetime value.
  • Case-sensitive UTM parameters: utm_source=google and utm_source=Google are tracked separately. Standardize your tag naming across all campaigns to avoid fragmented reports.
  • Forgetting to mark events as conversions. GA4 doesn't automatically treat purchase or sign_up as conversions—you must explicitly mark them in the Events admin panel. Otherwise, they won't appear in conversion reports or funnels.
  • Mixing up users and newUsers. GA4's newUsers metric counts only first-time visitors from the measurement period. activeUsers includes all users who triggered an event, regardless of whether they're new.

Wrapping Up

You now have a complete picture of how to track, query, and monitor user acquisition in GA4. Set up your UTM tags consistently, use the Data API to programmatically measure acquisition channels, and compare revenue or conversions by source to find your best-performing channels. If you want to track this automatically across tools—GA4, Mixpanel, Amplitude—Product Analyst can help.

Track these metrics automatically

Product Analyst connects to your stack and surfaces the insights that matter.

Try Product Analyst — Free