In this tutorial, we aim to guide you through the process of integrating Firebase Analytics into your Google Analytics account. This will allow you to view your Firebase app data directly in your Google Analytics dashboard.
What you will learn:
Prerequisites:
Linking Firebase and Google Analytics is done through the Firebase console. Here's how:
Log in to your Firebase console and select the project you want to link.
Click on "Project settings" in the left-hand menu.
Go to the "Integrations" tab and find the Google Analytics card.
Click "Link" and follow the prompts to link your Google Analytics account.
Once you've linked your accounts, Firebase data will be available in your Google Analytics dashboard. To view this:
Log in to your Google Analytics account.
Navigate to the account and property where you linked Firebase.
Go to the "Reports" section and select "Mobile apps".
Firebase data will appear here.
Unfortunately, there's no code involved in linking Firebase and Google Analytics. It's all done through the Firebase console. However, you can use the Firebase SDK to log custom events that will appear in Google Analytics.
Here's an example in JavaScript:
// Get a reference to the analytics service
var analytics = firebase.analytics();
// Log a custom event with optional parameters
analytics.logEvent('my_custom_event', {
param1: 'value1',
param2: 'value2'
});
This will log a custom event called 'my_custom_event' with two parameters. This event will appear in your Firebase data in Google Analytics.
In this tutorial, you've learned how to link Firebase and Google Analytics, and how to view Firebase data in Google Analytics. You've also seen an example of how to log custom events with the Firebase SDK.
For further learning, you could explore more about logging custom events and how to use these in your Google Analytics reports.
Exercise 1: Log into Firebase and Google Analytics and link your accounts.
Exercise 2: Log a custom event in Firebase and check that it appears in your Google Analytics reports.
Solutions:
Solution 1: Follow the steps in the guide above to link your accounts. If successful, you should see a confirmation message in Firebase.
Solution 2: Use the code example above to log a custom event, then navigate to your Google Analytics account and find the event in your reports. If you can't see it immediately, wait a few hours as it can take some time for events to appear.
For further practice, try logging different types of events with different parameters, and explore how these appear in Google Analytics.