Analytics - StansAssets/com.stansassets.android-native GitHub Wiki

A free and unlimited analytics solution. Analytics integrates across Firebase features and provides you with unlimited reporting for up to 500 distinct events that you can define using the Firebase SDK. Analytics reports help you understand clearly how your users behave, which enables you to make informed decisions regarding app marketing and performance optimizations.

he SDK logs two primary types of information:

  • Events: What is happening in your app, such as user actions, system events, or errors.
  • User properties: Attributes you define to describe segments of your user base, such as language preference or geographic location.

Before you begin

Before you can use the Google Analytics for Firebase, you will need to create a Firebase project, and add the Firebase Unity SDK packages to your Unity project. To use the API, you must first configure your game in the Firebase console. Import Firebase Unity SDK to your project. You only need FirebaseAnalytics.package. from the Firebase SDK.

Also, check out Google guide of how to set up FirebaseAnalytics.package.

API References

Use AN_FirebaseAnalytics class as an access point. See the code sample below:

using SA.Android.Firebase.Analytics;
...

AN_FirebaseAnalytics.LogEvent("my_event");

The full methods list will be described below:

Events:

/// <summary>
/// Logs an app event.
/// </summary>
/// <param name="eventName">event name.</param>
public static void LogEvent(string eventName);

/// <summary>
/// Logs an app event.
/// </summary>
/// <param name="eventName">event name.</param>
/// <param name="data">event data.</param>
public static void LogEvent(string eventName, IDictionary<string, object> data);

/// <summary>
/// Tracking Monetization (optional).
/// </summary>
/// <param name="productId">The id of the purchased item.</param>
/// <param name="amount">The price of the item.</param>
/// <param name="currency">
///  Abbreviation of the currency used for the transaction. For example “USD” (United
///  States Dollars). See http:en.wikipedia.orgwikiISO_4217 for a standardized list
///  of currency abbreviations.
/// </param>
public static void Transaction(string productId, float amount, string currency);

User properties:

/// <summary>
/// Sets the minimum engagement time required before starting a session. 
/// The default value 10 seconds.
/// </summary>
/// <param name="timeSpan">time span</param>
public static void SetMinimumSessionDuration(TimeSpan timeSpan);

/// <summary>
/// Sets the duration of inactivity that terminates the current session. 
/// The default value is (30 minutes).
/// </summary>
/// <param name="timeSpan">time span<</param>
public static void SetSessionTimeoutDuration(TimeSpan timeSpan);

Tracking settings:

/// <summary>
/// Sets the user ID property.
/// </summary>
/// <param name="userId">user id.</param>
public static void SetUserId(string userId);

/// <summary>
/// Sets a user property to a given value.
/// </summary>
/// <param name="name">property name.</param>
/// <param name="property">property value.</param>
public static void SetUserProperty(string name, string property);
⚠️ **GitHub.com Fallback** ⚠️