firebase: set user properties

本文介绍如何在Firebase中使用Analytics用户属性来描述应用用户群,并通过这些属性进行数据分析。文章详细解释了设置用户属性的方法,包括注册属性、添加代码以及查看报告等步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Set User Properties

User properties are attributes you define to describe segments of your user base, such as language preference or geographic location.

Analytics automatically logs some user properties; you don't need to add any code to enable them. If your app needs to collect additional data, you can set up to 25 different Analytics User Properties in your app.

Note:  The Age, Gender, and Interests properties are automatically collected only if your app links to theAd Support framework. Linking to this framework also automatically collects the Advertising Identifier (IDFA).

Before you begin

If this is your first time adding Analytics to your app, complete the following procedures:

Connect your app in the Firebase console

  1. Install the Firebase SDK.
  2. In the Firebase console, add your app to your Firebase project.

Add Analytics to your app

  1. Add the dependency for Firebase to your Podfile:
    
       
    pod 'Firebase/Core'
  2. Run pod install and open the created .xcworkspace file.
  3. Import the Firebase module in your UIApplicationDelegate:
    SWIFT
    OBJECTIVE-C
    
        
    @import Firebase ;
  4. Configure a FirebaseApp shared instance, typically in your application's application:didFinishLaunchingWithOptions: method:
    SWIFT
    OBJECTIVE-C
    
        
    // Use Firebase library to configure APIs
    [ FIRApp configure ];

Set user properties

You can set Analytics user properties to describe the users of your app. You can analyze behaviors of various user segments by applying these properties as filters to your reports.

Set a user property as follows:

  1. Register the property in the Analytics page of the Firebase console.

  2. Add code to set an Analytics user property with the setUserPropertyString() method. You can use the name and value of your choosing for each property.

The following example shows adding a hypothetical favorite food property, which assigns the value in the string food to the active user:

SWIFT

OBJECTIVE-C


  
[ FIRAnalytics setUserPropertyString : food forName :@ "favorite_food" ];
Note:  Once the property is registered, it can take several hours for data collected with the property to be included in reports. When the new data is available, the user property can be used as a report filter or audience definition.

You can access this data as follows:

  1. In the Firebase console, open your project.
  2. Select Analytics from the menu to view the Analytics reporting dashboard.

The User Properties tab shows a list of user properties that you have defined for your app. You can use these properties as a filter on many of the reports available in Google Analytics for Firebase. Read more about the Analytics reporting dashboard in the Firebase Help Center.

Note:  Data in the Analytics reporting dashboard refreshes periodically throughout the day

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值