简体   繁体   中英

How to set user Id and propeties in Firebase Analytics - Flutter

  • Goal: To save user ID and their properties, as he/she interacts with the flutter application.
  • Problem: Events are getting logged but i cant see user id and properties. I noticed it initially (that user id and properties arre not being logged) while working in debug mode, and then I also waited for 24-48 hours to check in the dashboard but no details for userId.
  • Documentation link: https://firebase.google.com/docs/analytics/userid#dart
  • and Yes the properties that I am trying to save in analytics, I have defined them in Custom definitions under User scope.
  • Code:
import 'package:firebase_analytics/firebase_analytics.dart';

class AnalyticsClass {
  static final AnalyticsClass _singleton = AnalyticsClass._internal();
  late FirebaseAnalytics fa = FirebaseAnalytics.instance;

  factory AnalyticsClass() {
    return _singleton;
  }

  AnalyticsClass._internal();

  buttonTap(id, name) async {
    await fa.logEvent(name: 'button_tap');
  }

  setUser(String id, name) async {
    await fa.setUserId(id: id);
    await fa.setUserProperty(name: 'referral', value: "test new : $name");
  }

  resetUser() async {
    await fa.setUserId(id: null);
    await fa.setUserProperty(name: 'referral', value: null);
  }
}

If you're using the setUserId() in Firebase, this does not show up in the Analytics reports due to privacy concerns. What you can do is to export your data to BigQuery . This will allow you to query your raw data as well as build custom reports via Data Studio . You may also consider using the User explorer in Google Analytics Dashboard which will help you gain more insight on the behavior of your individual users.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM