Skip to main content

Hi everyone,

I am afraid the answer to this question is No but in case this ever changes in the future I am still asking it.

Is it possible to export/integrate RevenueCat collected data into Google Firebase Analytics?

Thanks in advance for your reply.

I don’t think it’s possible to integrate directly since there isn’t a REST API to hook into Firebase Analytics - only device side tracking.

 

I would also love to know if anyone has found any creative solutions.

 

The best thing I know is to export the Firebase Analytics to Big Query, then set up a RevenueCat ETL to Google storage which you can also send into Big Query. 


As of late 2020 it is possible to log events from server-side code with the Analytics Data API and the GA4 Measurement Protocol documentation on sending events with this REST API, which you can use from Cloud Functions (and almost any other environment).

 

https://developers.google.com/analytics/devguides/collection/protocol/ga4/sending-events?client_type=firebase

 

The appInstanceID would need to be passed through somehow, possibly using RevenueCat Subscriber Attributes, or more directly, with a firebase collection that maps user_id to an appInstanceID.  It’s also possible that one valid appInstanceID could be used for all requests since user_id is a separate parameter to the REST API.  I’ll try and report back.


:fingers_crossed: It would be really useful to see the integration of RC sending events to Google Analytics / GA4!  Since we use RC as the source of truth for subscriptions and entitlements this is really a needed and useful connection.  Can this happen sometime soon?

 


Just an update here that this is something that we are actively exploring right now; expect more news in the next few months.


Just an update here that this is something that we are actively exploring right now; expect more news in the next few months.

Jens, any updates on this? I’ve created Firebase integration but still do not see events on Google Analytics side. Do you have any requirements for minimum SDK version that can properly support this functionality. So far I see that firebase app instance id is passed via subscriber attributes, so additional  client code is not required. I use Flutter SDK 2.0.3


Just an update here that this is something that we are actively exploring right now; expect more news in the next few months.

Jens, any updates on this? I’ve created Firebase integration but still do not see events on Google Analytics side. Do you have any requirements for minimum SDK version that can properly support this functionality. So far I see that firebase app instance id is passed via subscriber attributes, so additional  client code is not required. I use Flutter SDK 2.0.3

Hi Anastasiia, we have identified an issue where sometimes analytics events do not get delivered to Firebase and we are working on a fix. Expect to receive communication when this has been fixed.

 

CC @tina 


Hey @Anastasiia Stepanova 

A fix has been deployed last week, you should start seeing events populating in Google Analytics now. Check out the Realtime view to confirm you’re receiving events. Let us know if there’s any issues!


Hey @tina @Jens 

I am glad to hear updates from you, but I still do not see RC events on my Google Analytics dashboard. I’ve reported about this issue to my email thread with support team, hope we will be able to understand where is the issue.


The issue was in Google Analytics app instance id, it is not the same as Firebase app instance id.

  • Google Analytics app instance id is 32 HEX like this 9247fac65b9e4e76710904ae59ff0469
  • Firebase app instance id looks is 22 long like this Eol2-beETE-_cfkgTCswiQ

As soon as we’ve provided Google Analytics app instance id, RC events were displayed in the Google Analytics dashboard.


The issue was in Google Analytics app instance id, it is not the same as Firebase app instance id.

  • Google Analytics app instance id is 32 HEX like this 9247fac65b9e4e76710904ae59ff0469
  • Firebase app instance id looks is 22 long like this Eol2-beETE-_cfkgTCswiQ

As soon as we’ve provided Google Analytics app instance id, RC events were displayed in the Google Analytics dashboard.

How you get Google Analytics app instance id?


I know that it looks strange, my expectation was that Firebase app instance id is used everywhere in Firebase/Google ecosystem… I should note that I use not the latest libraries to get Firebase instance id, but they are not too old. I have checked this on pure Android Java implementation and get different ids by invoking two pieces of code:

 

Firebase app instance id:

FirebaseInstallations.getInstance().getId().addOnCompleteListener(new OnCompleteListener<String>() {    @Override    public void onComplete(@NonNull com.google.android.gms.tasks.Task<String> task) {            String appInstanceId= task.getResult();    }});

 

Google Analytics app instance id:

FirebaseAnalytics.getInstance(this).getAppInstanceId().addOnCompleteListener(new OnCompleteListener<String>() {    @Override    public void onComplete(@NonNull com.google.android.gms.tasks.Task<String> task) {            String appInstanceId = task.getResult();    }});

As for flutter I use 1.22.6, thus I had to write platform specific native code to get Google Analytics app instance id. I used this great library as a source:

https://github.com/cingulo/firebase_instance_id


I know that it looks strange, my expectation was that Firebase app instance id is used everywhere in Firebase/Google ecosystem… I should note that I use not the latest libraries to get Firebase instance id, but they are not too old. I have checked this on pure Android Java implementation and get different ids by invoking two pieces of code:

 

Firebase app instance id:

FirebaseInstallations.getInstance().getId().addOnCompleteListener(new OnCompleteListener<String>() {    @Override    public void onComplete(@NonNull com.google.android.gms.tasks.Task<String> task) {            String appInstanceId= task.getResult();    }});

 

Google Analytics app instance id:

FirebaseAnalytics.getInstance(this).getAppInstanceId().addOnCompleteListener(new OnCompleteListener<String>() {    @Override    public void onComplete(@NonNull com.google.android.gms.tasks.Task<String> task) {            String appInstanceId = task.getResult();    }});

As for flutter I use 1.22.6, thus I had to write platform specific native code to get Google Analytics app instance id. I used this great library as a source:

https://github.com/cingulo/firebase_instance_id

Thanks!


Just for reference in case someone face the same problem with using correct firebase analytics app instance id - https://stackoverflow.com/questions/62990995/what-is-the-difference-between-app-instance-id-and-instance-id-in-firebase


Just an update here that this is something that we are actively exploring right now; expect more news in the next few months.

Jens, any updates on this? I’ve created Firebase integration but still do not see events on Google Analytics side. Do you have any requirements for minimum SDK version that can properly support this functionality. So far I see that firebase app instance id is passed via subscriber attributes, so additional  client code is not required. I use Flutter SDK 2.0.3

Hi @Anastasiia Stepanova , how were you able to setup GA integration with Revenuecat? I was following this document but the code example is for iOS/Swift. We’re also developing our app with flutter and used the purchases_flutter package by revenuecat, but I can’t find the equivalent method in the package for this line of code:

Purchases.shared.attribution.setFirebaseAppInstanceID(unwrapped)

 


@penlab_kumu I provided example of native code that I used on Android side to get correct instance id. Read this thread. You should use this:

 

FirebaseAnalytics.getInstance(this).getAppInstanceId().addOnCompleteListener(new OnCompleteListener<String>() {    @Override    public void onComplete(@NonNull com.google.android.gms.tasks.Task<String> task) {            String appInstanceId = task.getResult();    }});


Hi! I see, you managed to solve this problem with Flutter. But we use Ionic and Firebase JS SDK. Is there any way to get correct “app_instance_id” from that SDK?


I found a solution, but it’s completely ugly. It’s better if RevenueCat had integration with Google Analytics.

1) Get Google Client ID

const getGoogleAnalyticsClientId = () => {
try {
return document.cookie.match(/_ga=(.+?);/)?1].split('.').slice(-2).join(".");
} catch(e) {
return undefined;
}
}

2) Set it as Attributes to Revenue Cat.

RevenueCat.Purchases.setAttributes({ 'ga_client_id': gaClientId })

3) Set up Web Hooks in Revenue Cat to deliver these events to your backend.

4) Set up backend to deliver these event to GA using Measurement Protocol.

const measurement_id = `G-XXXXXXXXXX`;
const api_secret = `<secret_value>`;

fetch(`https://www.google-analytics.com/mp/collect?measurement_id=${measurement_id}&api_secret=${api_secret}`, {
method: "POST",
body: JSON.stringify({
client_id: 'XXXXXXXXXX.YYYYYYYYYY',
events: n{
// Event names must start with an alphabetic character.
name: '_badEventName',
params: {},
}]
})
});

Details here https://developers.google.com/analytics/devguides/collection/protocol/ga4/sending-events?client_type=gtag#required_parameters


@Sergey Uniqs May I ask how this has been working out for you so far? We also use Ionic and would like to use the RC appID as the Firebase UserID. 


Reply