Get started with Google Analytics for C++ Stay organized with collections Save and categorize content based on your preferences.
Google Analytics collects usage and behavior data for your app. The SDKlogs two primary types of information:
- Events: What is happening in your app, such as user actions, systemevents, or errors.
- User properties: Attributes you define to describe segments of youruser base, such as language preference or geographic location.
Analytics automatically logs someevents anduser properties;you don't need to add any code to enable them. If your app needs to collectadditional data, you can set up to 25 differentAnalytics user propertiesand log up to 500 differentAnalytics eventtypes in your app.There is no limit on the total volume of events your app logs.
To access this data:
- In theFirebase console, open your project.
- SelectAnalytics from the menu to view theAnalyticsreporting dashboard.
TheEvents tab shows the event reports that areautomatically created for each distinct type ofAnalytics event logged byyour app. Read more about thedashboard.
To help you get started, theAnalytics SDK defines a number ofrecommended events that are common among different types of apps, includingretail and ecommerce, travel, and gaming apps. To learn more about these eventsand when to use them, seeRecommended events.To get the maximum detail in reports, logthe recommended events that make sense for your app and theirprescribed parameters. This also ensures that you benefit from the latestGoogle Analytics features as they become available.
Before you begin
Before you can useGoogle Analytics,you need to:
Register your C++ project and configure it to use Firebase.
If your C++ project already uses Firebase, then it's already registered andconfigured for Firebase.
Add theFirebaseC++ SDK to your C++ project.
Note that adding Firebase to your C++ project involves tasks both in theFirebase console and in your open C++ project (for example, you downloadFirebase config files from the console, then move them into your C++ project).
Create and initialize the firebase app
Before you start, you'll need to create and initialize the firebase App:
Android
Create the firebase app, passing the jni environment and ajobjectreference to the java activity as arguments:
app=::firebase::App::Create(::firebase::AppOptions(),jni_env,activity);
Initialize theAnalytics library:
::firebase::analytics::Initialize(app);
iOS+
Create the firebase app:
app=::firebase::App::Create(::firebase::AppOptions());
Initialize theAnalytics library:
::firebase::analytics::Initialize(app);
Log events
After you have configured thefirebase::App instance, you canbegin to log events with theLogEvent() method.
The following example updates the user's score:
analytics::LogEvent(analytics::kEventPostScore,analytics::kParameterScore,42);
Next steps
- See your data refresh periodically in theFirebase console.
- Explore the guides onevents anduser properties.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-02-18 UTC.