AppEventsLogger module allows you to log app events for analytics, track purchases, and manage user data for Facebook’s event tracking system.
Import
Methods
logEvent
Logs a custom app event with optional parameters and value.string
required
The name of the event to log. Use predefined events from
AppEventsLogger.AppEvents or custom event names.number
Optional numeric value to associate with the event for aggregation.
Params
Optional key-value pairs containing additional event data. Use predefined parameter keys from
AppEventsLogger.AppEventParams.logPurchase
Logs a purchase event with amount and currency.number
required
The amount of the purchase.
string
required
The ISO 4217 currency code (e.g., “USD”, “EUR”, “GBP”).
Params
Optional additional parameters for the purchase event.
logPushNotificationOpen
Logs that the app was opened via a push notification.Record<string, string | number>
Optional payload data from the push notification.
logProductItem
Uploads a product catalog item as an app event.string
required
Unique identifier for the product. Maximum 100 characters.
ProductAvailability
required
Product availability:
'in_stock', 'out_of_stock', 'preorder', 'avaliable_for_order', or 'discontinued'.ProductCondition
required
Product condition:
'new', 'refurbished', or 'used'.string
required
Product description. Maximum 5000 characters.
string
required
URL to the product image.
string
required
URL to the product page on your website.
string
required
Product title.
number
required
Product price (rounded to thousandths place).
string
required
ISO 4217 currency code.
string
Global Trade Item Number (UPC, EAN, JAN, ISBN).
string
Manufacturer Part Number.
string
Brand name.
Params
Additional parameters for deep linking.
At least one of
gtin, mpn, or brand must be provided.setUserID
Sets a custom user ID to associate with all app events.string | null
required
The user ID to set, or
null to clear the current user ID.getUserID
Returns the currently set user ID.getAnonymousID
Returns the anonymous ID for the current app installation.getAdvertiserID
Returns the advertiser ID (IDFA on iOS, Advertising ID on Android).getAttributionID
Returns the attribution ID. Android only.This method returns
null on iOS.setUserData
Sets additional user data to improve ad targeting and measurement.UserData
required
User information for advanced matching. See Advanced Matching for field format details.
setFlushBehavior
Controls when events are sent to Facebook servers.AppEventsFlushBehavior
required
Either
'auto' (default: flush every 15 seconds or 100 events) or 'explicit_only' (only flush when flush() is called).flush
Manually triggers sending queued events to Facebook servers.setPushNotificationsDeviceToken
Registers the device token for push notifications. iOS only.string
required
The APNs device token.
setPushNotificationsRegistrationId
Registers the registration ID for push notifications. Android only.string
required
The FCM registration ID.