Set Subscriber Attributes in RevenueCat

Overview

Subscriber attributes are key-value pieces of metadata you attach to a RevenueCat customer (the current app user id). They let you enrich a customer record with information such as an email address, a display name, a phone number, or your own app-specific data like the plan tier they signed up for. Attributes show up in the RevenueCat dashboard and can be forwarded to integrations.

There are two kinds of subscriber attributes:

  • Reserved attributes are predefined keys that RevenueCat recognizes by name, set with dedicated methods: setEmail, setDisplayName, and setPhoneNumber (among others).
  • Custom attributes are arbitrary key-value pairs you define yourself, set with setAttributes (for example plan_tier or favorite_color).
Prerequisites: The RevenueCat SDK must already be installed and configured with Purchases.configure(...). See the React Native codelab and the Configure the SDK guide for setup.

Reserved Attributes (setEmail, setDisplayName, setPhoneNumber)

Reserved attributes have dedicated setter methods because RevenueCat treats them specially: they are displayed in the customer view and mapped to fields that downstream integrations understand. The three most common are email, display name, and phone number.

typescript
import Purchases from 'react-native-purchases';

// Reserved attributes: RevenueCat recognizes these keys by name.
Purchases.setEmail('user@example.com');
Purchases.setDisplayName('Jane Doe');
Purchases.setPhoneNumber('+15551234567');
To delete a reserved attribute, set its value to an empty string. For example Purchases.setEmail('') clears the email for the current app user id. There is no separate delete method.

Custom Attributes (setAttributes)

For data that is specific to your app, use setAttributes with a map of your own keys to string values. This is where you store things like the subscription tier a user picked, an experiment bucket, or a preference. You can set several at once in a single call:

typescript
import Purchases from 'react-native-purchases';

// Custom attributes: your own keys and values.
Purchases.setAttributes({ 'favorite_color': 'blue', 'plan_tier': 'gold' });
Do not put secrets in attributes. Subscriber attributes are not designed for sensitive data such as passwords or tokens. Use them for descriptive, non-confidential metadata. To clear a custom attribute, pass an empty string as its value.

When to Set Them

Attributes are stored against the current app user id and synced to RevenueCat automatically (the SDK batches them, so you do not flush them manually). Two timing rules matter:

  • After configure(). Setting attributes before the SDK is configured means there is no user to attach them to. Configure first, then set attributes.
  • After logIn(). Because attributes belong to the current app user id, when you switch users with logIn() you should re-apply any identity-specific attributes (email, display name, phone) for the new user.
typescript
import Purchases from 'react-native-purchases';

// 1) Configure the SDK once at app start.
Purchases.configure({ apiKey: 'your_public_sdk_key' });

// 2) When the user signs in, switch the app user id...
await Purchases.logIn('user_database_id');

// 3) ...then re-apply identity-specific attributes for that user.
Purchases.setEmail('user@example.com');
Purchases.setDisplayName('Jane Doe');

See the Identify users with logIn and logOut guide for how app user ids work and when to call logIn().

Code Per Platform

The same concepts apply on every platform. The method names match, but the object you call them on differs. Below are the reserved setters and a custom setAttributes call for each SDK.

React Native

typescript
import Purchases from 'react-native-purchases';

Purchases.setEmail('user@example.com');
Purchases.setDisplayName('Jane Doe');
Purchases.setPhoneNumber('+15551234567');
Purchases.setAttributes({ 'favorite_color': 'blue', 'plan_tier': 'gold' });

iOS (Swift)

In purchases-ios v5 and later, the attribute setters live under the attribution namespace:

swift
import RevenueCat

// purchases-ios v5+: setters live under the attribution namespace.
Purchases.shared.attribution.setEmail("user@example.com")
Purchases.shared.attribution.setDisplayName("Jane Doe")
Purchases.shared.attribution.setPhoneNumber("+15551234567")
Purchases.shared.attribution.setAttributes(["favorite_color": "blue"])
purchases-ios v4 note. In v4 these setters were called directly on Purchases.shared, for example Purchases.shared.setEmail("user@example.com"). If you are unsure which form your SDK version uses, prefer the v5 attribution form above and check the official docs.

Android (Kotlin)

kotlin
import com.revenuecat.purchases.Purchases

Purchases.sharedInstance.setEmail("user@example.com")
Purchases.sharedInstance.setDisplayName("Jane Doe")
Purchases.sharedInstance.setPhoneNumber("+15551234567")
Purchases.sharedInstance.setAttributes(mapOf("favorite_color" to "blue"))

On every platform, the SDK batches attribute writes and syncs them to RevenueCat automatically in the background. You do not need to await the result of a setter or flush manually.

FAQ

How do I set a customer's email in RevenueCat?
Call setEmail after the SDK is configured: Purchases.setEmail('user@example.com') in React Native, Purchases.shared.attribution.setEmail("user@example.com") on iOS v5, and Purchases.sharedInstance.setEmail("user@example.com") on Android. Email is a reserved attribute, so RevenueCat recognizes it by name.

What is the difference between reserved and custom attributes?
Reserved attributes (setEmail, setDisplayName, setPhoneNumber) use predefined keys RevenueCat understands and surfaces in the dashboard and integrations. Custom attributes (setAttributes) are arbitrary key-value pairs you define yourself, such as plan_tier or favorite_color.

When should I set subscriber attributes?
After Purchases.configure(...) has run. Because attributes are tied to the current app user id, re-apply identity-specific ones after logIn() switches the user. The SDK batches and syncs them automatically.

How do I delete a subscriber attribute?
Set its value to an empty string, for example setEmail("") or an empty string for a custom key in setAttributes. Do not store secrets in attributes, since they are not designed for sensitive data.

Related Guides