How do I track custom user properties in GA4 (like membership level or plan type)?

Applies to: Google Analytics 4 (GA4)
Last updated: May 2025


Problem

You want to enrich your analytics by tracking custom user properties—such as membership tier, subscription status, or user role—to segment audiences and personalize reports.


Solution

GA4 allows you to set user properties programmatically using the GA4 gtag.js or the Firebase SDK (for apps). These properties are persistent across sessions and can be used in reports, segments, comparisons, and audiences.


Step-by-Step Guide

Step 1: Identify the Property You Want to Track

Examples of custom user properties:

  • membership_level (e.g., Free, Premium)
  • plan_type (e.g., Monthly, Annual)
  • user_role (e.g., Admin, Editor, Viewer)

Step 2: Set User Properties in Code

For Websites (gtag.js):
Add this code where user info becomes available (e.g., after login):

gtag('set', 'user_properties', {
membership_level: 'premium',
plan_type: 'monthly'
});

For Apps (Firebase):

// iOS (Swift)
Analytics.setUserProperty("premium", forName: "membership_level")
// Android (Java/Kotlin)
FirebaseAnalytics.getInstance(this).setUserProperty("membership_level", "premium");

Step 3: Register User Property in GA4

  1. Go to https://analytics.google.com
  2. Select your GA4 property
  3. Click Admin > Custom Definitions
  4. Click Create Custom Dimension
  5. Set:
    • Dimension name: e.g., Membership Level
    • Scope: User
    • User property: Must exactly match your code (e.g., membership_level)
  6. Save

GA4 will now start collecting and storing values for this property.


Step 4: Use in Reports and Explorations

  • In Explorations, add your custom dimension (e.g., Membership Level) to rows, filters, or comparisons
  • In User Reports, use the property to segment or filter data
  • Create audiences (e.g., Premium Users) based on property values

Use Cases

  • Filter by subscription plan in conversion reports
  • Segment returning users by membership type
  • Retarget specific user groups via Google Ads (if linked)

Notes

  • User properties are persisted and tied to the user across sessions
  • GA4 supports up to 25 custom user properties per property
  • Data is not retroactive—only collected after setup and registration