6 min read

How to Set Up Audiences in Google Analytics 4

Audiences in GA4 let you segment users based on their behavior and send those segments to your ad platforms. Unlike Universal Analytics, GA4 audiences are dynamic—they update in real-time as events match your criteria. If you're running ad campaigns and want to retarget based on actual product usage, you need audiences set up.

Create an Audience in the GA4 Admin Panel

The simplest way to create an audience is through the Google Analytics 4 interface.

Navigate to the Audiences section

In Google Analytics 4, go to Admin (bottom left) > Audiences under the "Data and Privacy" section. Click Create Audience to start.

Choose between a new audience or a template

GA4 offers pre-built audience templates (Purchasers, Active Users, etc.) or lets you build custom audiences. Select Create Custom Audience to define your own rules.

Set up audience conditions

Define who belongs to this audience. Use conditions like Event Name, Event Parameter, User Property, or Engagement Duration. For example, create an audience of users who triggered a purchase event with a value greater than $100.

javascript
// Audience definition in GA4 Admin API
{
  "displayName": "High-Value Customers",
  "description": "Users who purchased items totaling over $100",
  "membershipDurationDays": 30,
  "audienceDefinition": {
    "includeConditions": {
      "inclusionCriteria": [
        {
          "eventCondition": {
            "eventName": "purchase",
            "eventParameters": [
              {
                "name": "value",
                "numericValue": {
                  "value": 100.0,
                  "operation": "GREATER_THAN_OR_EQUAL"
                }
              }
            ]
          }
        }
      ]
    }
  }
}
GA4 audience definition with a purchase value condition

Save and activate the audience

Click Save to create the audience. GA4 will start populating it immediately based on incoming events. Note: audiences need at least 100 members before data is shown.

Tip: Audience conditions are ANDed together—if you set two conditions, users must match both to be included. If you want OR logic, create multiple audiences and combine them in your ad platform.

Send Events That Populate Your Audiences

Audiences only work if you're sending the right events. Make sure your event structure matches the audience conditions exactly.

Send events using the gtag library

Use the gtag() function to send events from your website or app. Include the event parameters that your audience conditions reference. For the high-value customer audience above, send a purchase event with a value parameter.

javascript
// Send a purchase event to GA4
gtag('event', 'purchase', {
  value: 150.00,
  currency: 'USD',
  items: [
    {
      item_id: 'SKU123',
      item_name: 'Premium Widget',
      price: 150.00,
      quantity: 1
    }
  ]
});
Example gtag purchase event that triggers audience inclusion

Use the Measurement Protocol for server-side events

If you're tracking purchases or conversions server-side (e.g., order confirmation), use the GA4 Measurement Protocol. Send events directly to Google's servers with your measurement ID and API secret.

javascript
// Send a server-side event via Measurement Protocol
const measurementId = 'G-XXXXXXXXXX';
const apiSecret = 'YOUR_API_SECRET';

fetch(`https://www.google-analytics.com/mp/collect`, {
  method: 'POST',
  body: JSON.stringify({
    measurement_id: measurementId,
    api_secret: apiSecret,
    client_id: 'USER_CLIENT_ID',
    events: [
      {
        name: 'purchase',
        params: {
          value: 150.00,
          currency: 'USD',
          items: [{ item_id: 'SKU123', item_name: 'Premium Widget' }]
        }
      }
    ]
  })
});
Server-side event submission using Measurement Protocol

Verify events in the Real-time report

Go to Reports > Real-time to confirm events are arriving in GA4. Check that event names and parameters match your audience conditions exactly. GA4 is case-sensitive—purchase is not the same as Purchase.

Watch out: Event parameter names and values are case-sensitive. If your audience looks for the parameter value but you're sending Value, the audience condition won't match.

Programmatically Create Audiences with the Admin API

For large-scale deployments, use the Google Analytics Admin API to create audiences without manually clicking through the UI.

Authenticate with the Admin API

Obtain a bearer token using OAuth 2.0 or a service account. Include the token in your API requests to analyticsadmin.googleapis.com.

javascript
// Authenticate using a service account
const { GoogleAuth } = require('google-auth-library');

const auth = new GoogleAuth({
  keyFilename: '/path/to/service-account-key.json',
  scopes: ['https://www.googleapis.com/auth/analytics.edit']
});

const accessToken = await auth.getAccessToken();
Obtaining access token for GA4 Admin API

Create an audience via the API

Call the POST endpoint for your property to create a new audience. Specify the audience definition with conditions, duration, and exclusion logic.

javascript
const propertyId = '123456789';
const accessToken = 'YOUR_ACCESS_TOKEN';

const audiencePayload = {
  displayName: 'Engaged Users',
  description: 'Users who visited 5+ pages in a session',
  membershipDurationDays: 14,
  audienceDefinition: {
    "includeConditions": {
      "inclusionCriteria": [
        {
          "eventCondition": {
            "eventName": "page_view",
            "eventParameters": [
              {
                "name": "engagement_time_msec",
                "numericValue": {
                  "value": 60000.0,
                  "operation": "GREATER_THAN"
                }
              }
            ]
          }
        }
      ]
    }
  }
};

const response = await fetch(
  `https://analyticsadmin.googleapis.com/v1beta/properties/${propertyId}/audiences`,
  {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${accessToken}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify(audiencePayload)
  }
);

const audience = await response.json();
console.log('Audience created:', audience.name);
Creating an audience using the GA4 Admin API
Tip: Audiences created via API take a few minutes to become active and start populating with members.

Common Pitfalls

  • Audiences only show data once they reach 100 members—GA4 hides smaller audiences for privacy. If your audience seems empty, check the Real-time report to see if events are coming in.
  • Audience conditions are ANDed together by default. If you want to include users matching condition A OR condition B, you need to create separate audiences and combine them in your ad platform.
  • Event parameter names and values are case-sensitive. If your audience looks for purchase but you send Purchase, the condition won't match.
  • Changing audience membership duration is permanent once saved—you can't retroactively adjust how long users stay in an audience. Plan this before creation.

Wrapping Up

Audiences in GA4 give you dynamic user segments based on real behavior. Whether you set them up through the UI or API, the key is ensuring your events match your audience conditions exactly. Once activated, audiences automatically update as new events arrive—no manual sync needed. If you want to track and segment users consistently across analytics, ads, and email, Product Analyst can help.

Track these metrics automatically

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

Try Product Analyst — Free