GA4 fundamentally changed how user acquisition works. Unlike Universal Analytics, GA4 counts every device as a new user on their first visit unless you set up user ID tracking. This means raw user counts are noise — you need first-touch dimensions and proper segmentation to understand where your customers actually come from.
Setting Up User Acquisition Tracking
GA4 automatically flags new users, but you need to configure it correctly to track acquisition by channel.
Step 1: Enable User ID Tracking in gtag.js
Add the gtag('config') command with your Measurement ID and set user_id to a persistent identifier (email hash, database ID, etc.). This tells GA4 to recognize the same person across devices.
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXXXXX', {
'user_id': 'user_12345',
'user_properties': {
'plan_type': 'premium'
}
});
// Set user ID after page load
gtag('set', {'user_id': 'user_12345'});Step 2: Track Acquisition Events
Use GA4's predefined sign_up event or create custom events to capture conversions. GA4 automatically attaches the user's first-touch source to these events.
// Track sign up with campaign details
gtag('event', 'sign_up', {
'method': 'google',
'value': 29.99,
'currency': 'USD',
'campaign': 'spring_launch'
});
// Track custom acquisition milestone
gtag('event', 'free_trial_start', {
'trial_length_days': 14,
'utm_source': 'linkedin',
'utm_campaign': 'brand_awareness'
});Step 3: View Acquisition Reports in GA4 UI
Navigate to Reports > Acquisition > User acquisition. GA4 shows new users segmented by Session source, Session medium, and Session campaign — the first-touch values from when the user appeared.
sign_up or page views.Analyzing Acquisition Data with the Reporting API
To export and analyze user acquisition programmatically, use the GA4 Reporting API. This is the only way to get raw acquisition data outside the UI.
Step 1: Initialize the Reporting API Client
Install the Google Analytics Data client library and authenticate with a service account. Create a service account in Google Cloud Console and grant it Editor access to your GA4 property.
// npm install @google-analytics/data
const {BetaAnalyticsDataClient} = require('@google-analytics/data');
const analyticsDataClient = new BetaAnalyticsDataClient({
keyFilename: 'path/to/service-account-key.json'
});
const propertyId = '123456789'; // From Admin > Property > Property IDStep 2: Query New Users by Source and Medium
Use firstUserSource and firstUserMedium dimensions with the newUsers metric. These are the canonical acquisition dimensions — they represent where each user came from on day one.
async function getAcquisitionMetrics() {
const [response] = await analyticsDataClient.runReport({
property: `properties/${propertyId}`,
dateRanges: [{
startDate: '2024-01-01',
endDate: '2024-03-26'
}],
dimensions: [
{name: 'firstUserSource'},
{name: 'firstUserMedium'},
{name: 'firstUserCampaign'}
],
metrics: [
{name: 'newUsers'},
{name: 'activeUsers'},
{name: 'conversions'}
]
});
return response;
}
const data = await getAcquisitionMetrics();Step 3: Aggregate and Export Results
Loop through the response rows and sum newUsers by source. This gives you the exact breakdown GA4 shows in the User acquisition report.
const acquisitionBreakdown = {};
data.rows?.forEach(row => {
const source = row.dimensionValues[0].value;
const medium = row.dimensionValues[1].value;
const campaign = row.dimensionValues[2].value;
const newUsers = parseInt(row.metricValues[0].value);
const key = `${source} / ${medium}`;
acquisitionBreakdown[key] = (acquisitionBreakdown[key] || 0) + newUsers;
});
console.log(acquisitionBreakdown);
// Output: { 'google / organic': 1250, 'facebook / social': 890, 'direct / none': 340 }Common Pitfalls
- Skipping user ID tracking — without it, GA4 treats every browser as a new user. You'll never identify repeat customers or cross-device behavior.
- Using 'Session source' instead of 'First user source' — Session source changes on every visit. For acquisition, always use firstUserSource and firstUserMedium.
- Misinterpreting 'new users' as 'active users' — new users are counted by Client ID on their first session, regardless of engagement. Filter by actual conversions or events.
- Ignoring dark traffic in 'direct' — GA4 buckets deep links, SMS opens, and app opens as 'direct / none'. These aren't true direct traffic — segment them separately if you track them.
Wrapping Up
User acquisition in GA4 depends on first-touch dimensions and the Reporting API. Enable user ID tracking, query firstUserSource and firstUserMedium from the API, and always check your date ranges for sufficient volume. If you want to track this automatically across tools, Product Analyst can help.