Before implementing the SDK, make sure you have the following:
An Android app that you can use to implement the Google Analytics
A new Google Analytics app property and view (profile).
Replace tracking id in the analytics.xml in your project's which located under Assets/Plugins/Android/res/values/analytics.xml
In the Google Analytics SDK for Android v2.x and higher, you can configure your EasyTracker implementation using parameters defined in your analytics.xml file. The table below lists all available parameters you can use for version 2 or higher of the Google Analytics SDK for Android. Table can be founded here
You can also get more information from Google Getting Started guide.
Start sending analytics to google, and will appear shortly in your report. Make sure you do this on your application start.
After this API call, you will able to track:
- App installations
- Active users and demographics
- Screens and user engagement
- Crashes and exceptions
if you want to change the default tracking id use this function after StartTracking:
But you can do much more with other API methods described below.
Tracking first screen
Send event example + 1 more implementation
AndroidGoogleAnalytics.Instance.SendEvent("Category", "Action", "label");
Send event example with addition values + 1 more implementation
AndroidGoogleAnalytics.Instance.SendEvent("Category", "Action", "label", 100, "screen", "main");
Send timing event + 2 more implementations
AndroidGoogleAnalytics.Instance.SendTiming("App Started", (long) Time.time);
Set session key
To remove session key use
To Change login level use
To disable data sending use
To enable advertising features requires a single addition to your Google Analytics tracking code to collect the advertising id
Advertising ID Retrieval
Since Advertizing ID is the part of Google Play Service id, you can found more information about it and code sample how to retrieve it in the Google Play Utilities article.
You can do much more with Google Analytics, including measuring campaigns, in-app payments and transactions, and user interaction events.
Review the Mobile App Implementation Guide for an overview of how to use Google Analytics to measure user interactions and answer questions about app usage.
The following developer guides provide additional details on how to implement Google Analytics features in your app:
- Demographics and Remarketing – Use Display Features to understand user demographic data like age/gender and create remarketing lists for re-engaging users.
- Measuring Events – Learn how to measure user engagement with interactive content like buttons, videos, and other media using Events.
- Measuring In-App Payments – Learn how to measure in-app payments and transactions.
- Measuring Campaigns – Learn how to implement campaign measurement to understand which channels and campaigns are driving app installs.
- User timings – Learn how to measure user timings in your app to measure load times, engagement with media and more.
- Advanced Configuration – Learn more about advanced configuration options, including using multiple trackers.
- Configuration Parameters – See the complete list of configuration parameters.
API use example can be found under the AnalyticsUseExample.cs script.