Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get user_pseudo_id from firebase client sdk?

In the Firebase Analytics, user_pseudo_id is automatically log into bigquery. But, I want to get this value in the firebase client sdk (ex: android, ios sdk) to specify user. I found on docs of firebase but couldnt found any reference about this issue of my. Have any suggest to get it?

Thanks so much!

like image 252
Phan Sinh Avatar asked Apr 20 '26 13:04

Phan Sinh


1 Answers

I just found it, it is documented here. I also tested that it returns values that I can find in the BigQuery user_pseudo_id column.

Example for android:

    FirebaseAnalytics.getInstance(this).getAppInstanceId().addOnCompleteListener(new OnCompleteListener<String>() {
        @Override
        public void onComplete(@NonNull Task<String> task) {
            if (task.isSuccessful()) {
                String user_pseudo_id = task.getResult();
            }
        }
    });

And for web I used the next snippet (tested on Feb 10th, 2023, I got the code from here):

var gaUserId = document.cookie.match(/_ga=(.+?);/)[1].split('.').slice(-2).join(".")

I am not sure about IOS but it may be this one.

like image 74
josue.0 Avatar answered Apr 22 '26 23:04

josue.0



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!