Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business


The Firebase Analytics item provides insights into your app's usage. More...

Import Statement: import Felgo 4.0
Since: Felgo 4.1.0




Detailed Description

Note: This item works with Google Analytics 4. It replaces the deprecated Universal Analytics and the Google Analytics Plugin. Find more information at the Google Analytics documentation.

On mobile platforms, it uses the native Firebase SDKs to send analytics data. On desktop platforms, it uses the GTAG API to send analytics data to a web stream.

Note: Check out the Firebase Plugin page for more examples!

Property Documentation

config : FirebaseConfig

This property defines the account configuration to use for this item. It includes the Firebase project ID, app ID, API key, database URL and more.

To use the default Firebase account defined in google-services.json and GoogleService-info.plist, do not assign this property or assign null.

Note: This property is currently unused for Firebase Analytics. This is because the native Firebase SDKs on Android and iOS do not allow using a custom Firebase configuration. It always uses the default configuration via GoogleService-Info.plist and google-services.json. The property currently only exists to offer similar API for all Firebase Plugin QML types.

measurementId : string

Sets the web measurement ID. Get this property from the Google Analytics admin dashboard. You can create a new web stream at Data Streams -> Add -> Web. Measurement IDs are in the form "G-ABCDE12345".

Note: This property is only used on desktop platforms. On mobile platforms, the Firebase SDK configures the data stream instead. See the section about Firebase Account for more info.

userId : string

Sets the user ID property. The userId is the ID of this app on this device, which must be non-empty and no more than 256 characters long. Setting userID to an empty string removes the user ID.

Method Documentation

void logEvent(string name, variant params)

Log a single event with a name and JSON-encoded params.

The name should contain 1 to 40 alphanumeric characters or underscores. The name must start with an alphabetic character. Note that event names are case-sensitive and that logging two events whose names differ only in case will result in two distinct events.

The params is a map of event parameters. Passing null indicates that the event has no parameters. Parameter names can be up to 40 characters long and must start with an alphabetic character and contain only alphanumeric characters and underscores. String, long and double param types are supported. String parameter values can be up to 100 characters long.

Note: The "firebase_", "google_" and "ga_" prefixes are reserved and should not be used for parameter names.


    firebaseAnalytics.logEvent("registered_account", {"type": "facebook"});

void logScreen(string screenName)

Screens in Google Analytics represent content users are viewing within your app (like a pageview in web). Measuring screen views allows you to see which content is being viewed most by your users, and how are they are navigating between different pieces of content.

A screen view consists of a single string field called screenName that will be used as the screen name in your Google Analytics reports.

void resetAnalyticsData()

Resets the internal analytics state.

After a call to this method, events and screen views will be attributed to a new device and user.

Calling this method resets the current internal session ID and client ID.

Note: It also resets the userId and user properties. You can set them afterwards again to track user data again.

void setUserProperty(string name, variant value)

Sets a user property to a given value. Up to 25 user property names are supported. Once set, user property values persist throughout the app lifecycle and across sessions

User properties are attributes you define to describe segments of your user base, such as language preference or geographic location.

The name should contain 1 to 24 alphanumeric characters or underscores and must start with an alphabetic character.

Note: The "firebase_", "google_" and "ga_" prefixes are reserved and should not be used for user property names.

The value can be up to 36 characters long. Setting the value to null removes the user property.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded