The Firebase Analytics service interface.
Do not call this constructor directly. Instead, usefirebase.analytics().
Index
Properties
app
Theapp associated with theAnalytics serviceinstance.
- example
var app = analytics.app;
Methods
logEvent
- log
Event(eventName: "add_payment_info", eventParams?: {coupon?:EventParams["coupon"];currency?:EventParams["currency"];items?:EventParams["items"];payment_type?:EventParams["payment_type"];value?:EventParams["value"] }, options?: AnalyticsCallOptions):void Sends analytics event with given
eventParams. This methodautomatically associates this logged event with this Firebase webapp instance on this device.List of recommended event parameters can be found in the GA4 reference documentation.Parameters
eventName:"add_payment_info"
Optional eventParams:{coupon?:EventParams["coupon"];currency?:EventParams["currency"];items?:EventParams["items"];payment_type?:EventParams["payment_type"];value?:EventParams["value"] }
[key:string]:any
Optional coupon?:EventParams["coupon"]
Optional currency?:EventParams["currency"]
Optional items?:EventParams["items"]
Optional payment_
type?:EventParams["payment_type"] Optional value?:EventParams["value"]
Optional options:AnalyticsCallOptions
Returnsvoid
- log
Event(eventName: "add_shipping_info", eventParams?: {coupon?:EventParams["coupon"];currency?:EventParams["currency"];items?:EventParams["items"];shipping_tier?:EventParams["shipping_tier"];value?:EventParams["value"] }, options?: AnalyticsCallOptions):void Sends analytics event with given
eventParams. This methodautomatically associates this logged event with this Firebase webapp instance on this device.List of recommended event parameters can be found in the GA4 reference documentation.Parameters
eventName:"add_shipping_info"
Optional eventParams:{coupon?:EventParams["coupon"];currency?:EventParams["currency"];items?:EventParams["items"];shipping_tier?:EventParams["shipping_tier"];value?:EventParams["value"] }
[key:string]:any
Optional coupon?:EventParams["coupon"]
Optional currency?:EventParams["currency"]
Optional items?:EventParams["items"]
Optional shipping_
tier?:EventParams["shipping_tier"] Optional value?:EventParams["value"]
Optional options:AnalyticsCallOptions
Returnsvoid
- log
Event(eventName: "add_to_cart" |"add_to_wishlist" |"remove_from_cart", eventParams?: {currency?:EventParams["currency"];items?:EventParams["items"];value?:EventParams["value"] }, options?: AnalyticsCallOptions):void Sends analytics event with given
eventParams. This methodautomatically associates this logged event with this Firebase webapp instance on this device.List of recommended event parameters can be found in the GA4 reference documentation.Parameters
eventName:"add_to_cart" |"add_to_wishlist" |"remove_from_cart"
Optional eventParams:{currency?:EventParams["currency"];items?:EventParams["items"];value?:EventParams["value"] }
[key:string]:any
Optional currency?:EventParams["currency"]
Optional items?:EventParams["items"]
Optional value?:EventParams["value"]
Optional options:AnalyticsCallOptions
Returnsvoid
- log
Event(eventName: "begin_checkout", eventParams?: {coupon?:EventParams["coupon"];currency?:EventParams["currency"];items?:EventParams["items"];value?:EventParams["value"] }, options?: AnalyticsCallOptions):void Sends analytics event with given
eventParams. This methodautomatically associates this logged event with this Firebase webapp instance on this device.List of recommended event parameters can be found in the GA4 reference documentation.Parameters
eventName:"begin_checkout"
Optional eventParams:{coupon?:EventParams["coupon"];currency?:EventParams["currency"];items?:EventParams["items"];value?:EventParams["value"] }
[key:string]:any
Optional coupon?:EventParams["coupon"]
Optional currency?:EventParams["currency"]
Optional items?:EventParams["items"]
Optional value?:EventParams["value"]
Optional options:AnalyticsCallOptions
Returnsvoid
- log
Event(eventName: "checkout_progress", eventParams?: {checkout_option?:EventParams["checkout_option"];checkout_step?:EventParams["checkout_step"];coupon?:EventParams["coupon"];currency?:EventParams["currency"];items?:EventParams["items"];value?:EventParams["value"] }, options?: AnalyticsCallOptions):void Sends analytics event with given
eventParams. This methodautomatically associates this logged event with this Firebase webapp instance on this device.List of recommended event parameters can be found in the GA4 reference documentation.Parameters
eventName:"checkout_progress"
Optional eventParams:{checkout_option?:EventParams["checkout_option"];checkout_step?:EventParams["checkout_step"];coupon?:EventParams["coupon"];currency?:EventParams["currency"];items?:EventParams["items"];value?:EventParams["value"] }
[key:string]:any
Optional checkout_
option?:EventParams["checkout_option"] Optional checkout_
step?:EventParams["checkout_step"] Optional coupon?:EventParams["coupon"]
Optional currency?:EventParams["currency"]
Optional items?:EventParams["items"]
Optional value?:EventParams["value"]
Optional options:AnalyticsCallOptions
Returnsvoid
- log
Event(eventName: "exception", eventParams?: {description?:EventParams["description"];fatal?:EventParams["fatal"] }, options?: AnalyticsCallOptions):void Sends analytics event with given
eventParams. This methodautomatically associates this logged event with this Firebase webapp instance on this device.See Measure exceptions.Parameters
eventName:"exception"
Optional eventParams:{description?:EventParams["description"];fatal?:EventParams["fatal"] }
[key:string]:any
Optional description?:EventParams["description"]
Optional fatal?:EventParams["fatal"]
Optional options:AnalyticsCallOptions
Returnsvoid
- log
Event(eventName: "generate_lead", eventParams?: {currency?:EventParams["currency"];value?:EventParams["value"] }, options?: AnalyticsCallOptions):void Sends analytics event with given
eventParams. This methodautomatically associates this logged event with this Firebase webapp instance on this device.List of recommended event parameters can be found in the GA4 reference documentation.Parameters
eventName:"generate_lead"
Optional eventParams:{currency?:EventParams["currency"];value?:EventParams["value"] }
[key:string]:any
Optional currency?:EventParams["currency"]
Optional value?:EventParams["value"]
Optional options:AnalyticsCallOptions
Returnsvoid
- log
Event(eventName: "login", eventParams?: {method?:EventParams["method"] }, options?: AnalyticsCallOptions):void Sends analytics event with given
eventParams. This methodautomatically associates this logged event with this Firebase webapp instance on this device.List of recommended event parameters can be found in the GA4 reference documentation.Parameters
eventName:"login"
Optional eventParams:{method?:EventParams["method"] }
[key:string]:any
Optional method?:EventParams["method"]
Optional options:AnalyticsCallOptions
Returnsvoid
- log
Event(eventName: "page_view", eventParams?: {page_location?:string;page_path?:string;page_title?:string }, options?: AnalyticsCallOptions):void Sends analytics event with given
eventParams. This methodautomatically associates this logged event with this Firebase webapp instance on this device.See Page views.Parameters
eventName:"page_view"
Optional eventParams:{page_location?:string;page_path?:string;page_title?:string }
[key:string]:any
Optional page_
location?:string Optional page_
path?:string Optional page_
title?:string
Optional options:AnalyticsCallOptions
Returnsvoid
- log
Event(eventName: "purchase" |"refund", eventParams?: {affiliation?:EventParams["affiliation"];coupon?:EventParams["coupon"];currency?:EventParams["currency"];items?:EventParams["items"];shipping?:EventParams["shipping"];tax?:EventParams["tax"];transaction_id:EventParams["transaction_id"];value?:EventParams["value"] }, options?: AnalyticsCallOptions):void Sends analytics event with given
eventParams. This methodautomatically associates this logged event with this Firebase webapp instance on this device.List of recommended event parameters can be found in the GA4 reference documentation.Parameters
eventName:"purchase" |"refund"
Optional eventParams:{affiliation?:EventParams["affiliation"];coupon?:EventParams["coupon"];currency?:EventParams["currency"];items?:EventParams["items"];shipping?:EventParams["shipping"];tax?:EventParams["tax"];transaction_id:EventParams["transaction_id"];value?:EventParams["value"] }
[key:string]:any
Optional affiliation?:EventParams["affiliation"]
Optional coupon?:EventParams["coupon"]
Optional currency?:EventParams["currency"]
Optional items?:EventParams["items"]
Optional shipping?:EventParams["shipping"]
Optional tax?:EventParams["tax"]
transaction_
id:EventParams["transaction_id"] Optional value?:EventParams["value"]
Optional options:AnalyticsCallOptions
Returnsvoid
- log
Event(eventName: "screen_view", eventParams?: {firebase_screen:EventParams["firebase_screen"];firebase_screen_class:EventParams["firebase_screen_class"] }, options?: AnalyticsCallOptions):void Sends analytics event with given
eventParams. This methodautomatically associates this logged event with this Firebase webapp instance on this device.See Track Screenviews.Parameters
eventName:"screen_view"
Optional eventParams:{firebase_screen:EventParams["firebase_screen"];firebase_screen_class:EventParams["firebase_screen_class"] }
[key:string]:any
firebase_
screen:EventParams["firebase_screen"] firebase_
screen_ class:EventParams["firebase_screen_class"]
Optional options:AnalyticsCallOptions
Returnsvoid
- log
Event(eventName: "search" |"view_search_results", eventParams?: {search_term?:EventParams["search_term"] }, options?: AnalyticsCallOptions):void Sends analytics event with given
eventParams. This methodautomatically associates this logged event with this Firebase webapp instance on this device.List of recommended event parameters can be found in the GA4 reference documentation.Parameters
eventName:"search" |"view_search_results"
Optional eventParams:{search_term?:EventParams["search_term"] }
[key:string]:any
Optional search_
term?:EventParams["search_term"]
Optional options:AnalyticsCallOptions
Returnsvoid
- log
Event(eventName: "select_content", eventParams?: {content_type?:EventParams["content_type"];item_id?:EventParams["item_id"] }, options?: AnalyticsCallOptions):void Sends analytics event with given
eventParams. This methodautomatically associates this logged event with this Firebase webapp instance on this device.List of recommended event parameters can be found in the GA4 reference documentation.Parameters
eventName:"select_content"
Optional eventParams:{content_type?:EventParams["content_type"];item_id?:EventParams["item_id"] }
[key:string]:any
Optional content_
type?:EventParams["content_type"] Optional item_
id?:EventParams["item_id"]
Optional options:AnalyticsCallOptions
Returnsvoid
- log
Event(eventName: "select_item", eventParams?: {item_list_id?:EventParams["item_list_id"];item_list_name?:EventParams["item_list_name"];items?:EventParams["items"] }, options?: AnalyticsCallOptions):void Sends analytics event with given
eventParams. This methodautomatically associates this logged event with this Firebase webapp instance on this device.List of recommended event parameters can be found in the GA4 reference documentation.Parameters
eventName:"select_item"
Optional eventParams:{item_list_id?:EventParams["item_list_id"];item_list_name?:EventParams["item_list_name"];items?:EventParams["items"] }
[key:string]:any
Optional item_
list_ id?:EventParams["item_list_id"] Optional item_
list_ name?:EventParams["item_list_name"] Optional items?:EventParams["items"]
Optional options:AnalyticsCallOptions
Returnsvoid
- log
Event(eventName: "select_promotion" |"view_promotion", eventParams?: {items?:EventParams["items"];promotion_id?:EventParams["promotion_id"];promotion_name?:EventParams["promotion_name"] }, options?: AnalyticsCallOptions):void Sends analytics event with given
eventParams. This methodautomatically associates this logged event with this Firebase webapp instance on this device.List of recommended event parameters can be found in the GA4 reference documentation.Parameters
eventName:"select_promotion" |"view_promotion"
Optional eventParams:{items?:EventParams["items"];promotion_id?:EventParams["promotion_id"];promotion_name?:EventParams["promotion_name"] }
[key:string]:any
Optional items?:EventParams["items"]
Optional promotion_
id?:EventParams["promotion_id"] Optional promotion_
name?:EventParams["promotion_name"]
Optional options:AnalyticsCallOptions
Returnsvoid
- log
Event(eventName: "set_checkout_option", eventParams?: {checkout_option?:EventParams["checkout_option"];checkout_step?:EventParams["checkout_step"] }, options?: AnalyticsCallOptions):void Sends analytics event with given
eventParams. This methodautomatically associates this logged event with this Firebase webapp instance on this device.List of recommended event parameters can be found in the GA4 reference documentation.Parameters
eventName:"set_checkout_option"
Optional eventParams:{checkout_option?:EventParams["checkout_option"];checkout_step?:EventParams["checkout_step"] }
[key:string]:any
Optional checkout_
option?:EventParams["checkout_option"] Optional checkout_
step?:EventParams["checkout_step"]
Optional options:AnalyticsCallOptions
Returnsvoid
- log
Event(eventName: "share", eventParams?: {content_type?:EventParams["content_type"];item_id?:EventParams["item_id"];method?:EventParams["method"] }, options?: AnalyticsCallOptions):void Sends analytics event with given
eventParams. This methodautomatically associates this logged event with this Firebase webapp instance on this device.List of recommended event parameters can be found in the GA4 reference documentation.Parameters
eventName:"share"
Optional eventParams:{content_type?:EventParams["content_type"];item_id?:EventParams["item_id"];method?:EventParams["method"] }
[key:string]:any
Optional content_
type?:EventParams["content_type"] Optional item_
id?:EventParams["item_id"] Optional method?:EventParams["method"]
Optional options:AnalyticsCallOptions
Returnsvoid
- log
Event(eventName: "sign_up", eventParams?: {method?:EventParams["method"] }, options?: AnalyticsCallOptions):void Sends analytics event with given
eventParams. This methodautomatically associates this logged event with this Firebase webapp instance on this device.List of recommended event parameters can be found in the GA4 reference documentation.Parameters
eventName:"sign_up"
Optional eventParams:{method?:EventParams["method"] }
[key:string]:any
Optional method?:EventParams["method"]
Optional options:AnalyticsCallOptions
Returnsvoid
- log
Event(eventName: "timing_complete", eventParams?: {event_category?:string;event_label?:string;name:string;value:number }, options?: AnalyticsCallOptions):void Sends analytics event with given
eventParams. This methodautomatically associates this logged event with this Firebase webapp instance on this device.List of recommended event parameters can be found in the GA4 reference documentation.Parameters
eventName:"timing_complete"
Optional eventParams:{event_category?:string;event_label?:string;name:string;value:number }
[key:string]:any
Optional event_
category?:string Optional event_
label?:string name:string
value:number
Optional options:AnalyticsCallOptions
Returnsvoid
- log
Event(eventName: "view_cart" |"view_item", eventParams?: {currency?:EventParams["currency"];items?:EventParams["items"];value?:EventParams["value"] }, options?: AnalyticsCallOptions):void Sends analytics event with given
eventParams. This methodautomatically associates this logged event with this Firebase webapp instance on this device.List of recommended event parameters can be found in the GA4 reference documentation.Parameters
eventName:"view_cart" |"view_item"
Optional eventParams:{currency?:EventParams["currency"];items?:EventParams["items"];value?:EventParams["value"] }
[key:string]:any
Optional currency?:EventParams["currency"]
Optional items?:EventParams["items"]
Optional value?:EventParams["value"]
Optional options:AnalyticsCallOptions
Returnsvoid
- log
Event(eventName: "view_item_list", eventParams?: {item_list_id?:EventParams["item_list_id"];item_list_name?:EventParams["item_list_name"];items?:EventParams["items"] }, options?: AnalyticsCallOptions):void Sends analytics event with given
eventParams. This methodautomatically associates this logged event with this Firebase webapp instance on this device.List of recommended event parameters can be found in the GA4 reference documentation.Parameters
eventName:"view_item_list"
Optional eventParams:{item_list_id?:EventParams["item_list_id"];item_list_name?:EventParams["item_list_name"];items?:EventParams["items"] }
[key:string]:any
Optional item_
list_ id?:EventParams["item_list_id"] Optional item_
list_ name?:EventParams["item_list_name"] Optional items?:EventParams["items"]
Optional options:AnalyticsCallOptions
Returnsvoid
- log
Event<T>(eventName: CustomEventName<T>, eventParams?: {}, options?: AnalyticsCallOptions):void Sends analytics event with given
eventParams. This methodautomatically associates this logged event with this Firebase webapp instance on this device.List of recommended event parameters can be found in the GA4 reference documentation.Type parameters
T:string
Parameters
eventName:CustomEventName<T>
Optional eventParams:{}
[key:string]:any
Optional options:AnalyticsCallOptions
Returnsvoid
setAnalyticsCollectionEnabled
- set
Analytics Collection Enabled(enabled: boolean):void Sets whether analytics collection is enabled for this app on this device.window['ga-disable-analyticsId'] = true;
Parameters
enabled:boolean
Returnsvoid
setCurrentScreen
- set
Current Screen(screenName: string, options?: AnalyticsCallOptions):void - deprecated
UselogEvent with
eventNameas 'screen_view' and add relevanteventParams.See Track Screenviews.
Use gtag 'config' command to set 'screen_name'.
Parameters
screenName:string
Optional options:AnalyticsCallOptions
Returnsvoid
setUserId
- set
User Id(id: string, options?: AnalyticsCallOptions):void Use gtag 'config' command to set 'user_id'.
Parameters
id:string
Optional options:AnalyticsCallOptions
Returnsvoid
setUserProperties
- set
User Properties(properties: CustomParams, options?: AnalyticsCallOptions):void Use gtag 'config' command to set all params specified.
Parameters
properties:CustomParams
Optional options:AnalyticsCallOptions
Returnsvoid
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 2022-07-27 UTC.