com.google.firebase.analytics

Contains public API classes for Firebase Analytics.

Classes

ConsentBuilder

Helper class used to enable fluent syntax in setConsent.

FirebaseAnalytics

The top level Firebase Analytics singleton that provides methods for logging events and setting user properties.

FirebaseAnalytics.Event

An Event is an important occurrence in your app that you want to measure.

FirebaseAnalytics.Param

Params supply information that contextualize Events.

FirebaseAnalytics.UserProperty

A UserProperty is an attribute that describes the app-user.

GoogleAnalyticsServerPreviewActivity

An Activity to preview or stop previewing a server-side Google Tag Manager container.

ParametersBuilder

Helper class used to enable fluent syntax in logEvent.

Enums

FirebaseAnalytics.ConsentStatus

The status value of the consent type.

FirebaseAnalytics.ConsentType

The type of consent to set.

Extension functions summary

inline Unit

Fluent version of FirebaseAnalytics.logEvent.

inline Unit
FirebaseAnalytics.setConsent(crossinline block: ConsentBuilder.() -> Unit)

Fluent version of FirebaseAnalytics.setConsent.

Extension properties summary

FirebaseAnalytics

Returns the FirebaseAnalytics instance of the default FirebaseApp.

Extension functions

logEvent

inline fun FirebaseAnalytics.logEvent(name: String, block: ParametersBuilder.() -> Unit): Unit

Fluent version of FirebaseAnalytics.logEvent.

Example use:

Firebase.analytics.logEvent("myEvent") {
param(Params.VALUE, 3.99)
param(Params.CURRENCY, "USD")
}

setConsent

inline fun FirebaseAnalytics.setConsent(crossinline block: ConsentBuilder.() -> Unit): Unit

Fluent version of FirebaseAnalytics.setConsent.

Example use:

Firebase.analytics.setConsent {
adStorage = ConsentStatus.GRANTED
analyticsStorage = ConsentStatus.GRANTED
adUserData = ConsentStatus.GRANTED
adPersonalization = ConsentStatus.GRANTED
}

Extension properties

analytics

val Firebase.analyticsFirebaseAnalytics

Returns the FirebaseAnalytics instance of the default FirebaseApp.