Better Together: Clarity + Firebase

Say goodbye to guesswork and hello to a new level of insight with Clarity and Firebase! 

Now, you can gain more understanding of your customers, not only by knowing what happened, but also by knowing why it happened! By linking Clarity session recordings with Firebase, you can now access your session and user URLs directly on each of your Firebase events/screens, making it a breeze to watch video recordings and analyze the entire user experience.  

Starting 2.1.0, We have introduced the getCurrentsessionURL API, that allows you to send and connect analytical events with Clarity. This URL is versatile and can be used with popular analytics tools like Firebase, Mixpanel, and others. In this blog, we will describe the steps needed to link Clarity’s session recordings with Firebase Analytics and Crashlytics SDKs. 


Note: You need to have a Firebase Google Analytics account and a Clarity account. If you don’t have one, Create one here

In Firebase

  1. On your Firebase project Dashboard, under the Analytics section click on Custom Definitions and then go to “Create custom dimensions”. 
  1. Give your dimension a descriptive name and parameter.  
  1. Add an “event parameter” to this dimension in. This parameter will contain the Clarity session recording URL.

In your app: 

Note: You should already have a Clarity project with Clarity’s Mobile SDK successfully integrated. If you don’t, Get started here

  1. Navigate to the section where you initialize Clarity. (ex: MainActivity). 
  1. Add callback function “Clarity.SetonNewSessionStartedCallback. This function will be triggered whenever a new clarity session starts. 
  1. Get the session URL, using the clarity.getCurrentSessionURL API to get the current sessions URL that is to be sent to Firebase Analytics. 
  1. Ensure that the Event name that you use in Clarity and the Event Parameter are the same that you’ve created on Firebase. 

To view Clarity’s sessions in Firebase: 

  1. Navigate to your Analytics Dashboard in Firebase. 
  1. View/add custom parameters to your events. For events, click on the session_started event. 
  1. Navigate down to the custom parameters card. Double-click on clarity_links to highlight the value, then copy it in a new browser window. 
  2. You should now see the session recording that contains session_started event in Clarity’s dashboard. 

For pages/screens, you can also see the same information by adding a custom parameter to the page/screen. 

Events in Firebase can take up to 24 hours to appear in the dashboard, but if you want to make sure that you are logging the events properly, run the following command, then check the Firebase debug view. 

adb shell setprop "yourpackagename" 

Firebase Crashlytics 

If you are using crashyltics SDK to collect your app crashes, you can just follow the same steps by calling the clarity.SetInNewSessionStartedCallback function where Clarity is initialized.  

You can view Clarity sessions’ and users’ link in the Keys section of your crashed session within Firebase console. 

If a crash occurs in your mobile app, you can gain valuable insights by analyzing the session and video recording where the crash took place. This will provide you with more context on the crash and help you understand how it affected the user journey. Additionally, you can analyze user behavior after experiencing a crash by checking the user sessions in Clarity’s user profile. By doing so, you can identify any patterns or trends that may be contributing to crashes and take steps to improve your app’s performance and user experience. 

By combining the detailed session recordings of Clarity with the robust analytics of Firebase, developers and marketers now have a powerful tool at their disposal.