How to use User Attributes in RevenueCat?

4 min

May 6, 2024

In today's competitive mobile app landscape, user engagement is the key to success. The ability to understand and cater to the individual needs and preferences of your users can significantly enhance their experience and ultimately drive growth for your application. One powerful tool that mobile app developers have at their disposal is the utilization of user attributes. These attributes, which encompass a wide range of user-related variables, can be leveraged to personalize user interactions, tailor content, and drive meaningful engagement.

In this article, we'll delve into the concept of user attributes and explore how developers can effectively integrate them into their applications. Specifically, we'll focus on the capabilities provided by platforms like RevenueCat, which empower developers to store and manage user attributes directly, without the need for complex backend infrastructure.

Practical Case: We have application which has In App's or Subscriptions, but it is important to give user some free attempts. How to do it without backend? Here RevenueCat comes.

Official package gives ability to set data, we can easily see it then on Console.

But what if want to fetch this data?

Here we should use direct GET call to one of RevenueCat apis. We can't get attributes with package, as we set them.

Future<Map<String, dynamic>> getAttributes(String customerId) async {
    try {
      Response<dynamic> response = await Get.find<DioProvider>().client.get(
          options: Options(headers: {"Authorization": "Bearer $API_KEY"}));
      if ((['subscriber'] as Map).containsKey('subscriber_attributes')) {
        return (['subscriber']['subscriber_attributes'] as Map<String, dynamic>);
      } else {
        return {};
    } catch (e) {
      return {};

This is example how we call api and take exactly Attributes from Response. Two variables to find:

  1. User id

    String userId = await Purchases.appUserID;

    RevenueCat package provides this field for user.

  2. RevenueCat Api Key

This one we should create on RevenueCat console.

Open Settings of your App

Click "API Keys"

Click "New"

Choose "V1" and fill "Name" field.

And… We are done, thank you for your time!

Get FlutterPlate

I left here 50% discount promocode "UYOTI0MQ" tshhh…🤫

Ship apps faster.