Android SDK Version
- Mutable
- CollectionMapper
- AppCall
- CustomTab
- CustomTabUtils
- DialogFeature
- DialogPresenter
- FacebookDialogBase
- FacebookDialogFragment
- GamingAction
- FacebookWebFallbackDialog
- FragmentWrapper
- InstagramCustomTab
- PlatformServiceClient
- WebDialog
- AnalyticsEvents
- AttributionIdentifiers
- BoltsMeasurementEventListener
- BundleJSONConverter
- CallbackManagerImpl
- FacebookInitProvider
- FacebookRequestErrorClassification
- FacebookSignatureValidator
- FeatureManager
- FetchedAppGateKeepersManager
- FetchedAppSettings
- FetchedAppSettingsManager
- FileLruCache
- ImageDownloader
- ImageRequest
- ImageResponse
- ImageResponseCache
- InstallReferrerUtil
- InternalSettings
- LockOnGetVariable
- Logger
- NativeAppCallAttachmentStore
- NativeProtocol
- ServerProtocol
- SmartLoginOption
- UrlRedirectCache
- Utility
- Validate
- WorkQueue
- MessageDialog
- SendButton
- ShareButton
- ShareButtonBase
- GameRequestDialog
- ShareDialog
- MessageDialogFeature
- VideoUploader
- GameRequestValidation
- CameraEffectFeature
- CameraEffectJSONUtility
- LegacyNativeDialogParameters
- NativeDialogParameters
- ResultProcessor
- ShareConstants
- ShareContentValidation
- ShareDialogFeature
- ShareFeedContent
- ShareInternalUtility
- ShareStoryFeature
- WebDialogParameters
- ShareApi
- ShareBuilder
- Sharer
- Share
- ShareToMessengerParamsBuilder
- Messenger
- MessengerThreadParams
- MessengerUtils
- ShareToMessengerParams
- FacebookAppLinkResolver
- AppLinkData
- AppLinks
- AggregateException
- AppLink
- AppLinkResolver
- AppLinks
- CancellationToken
- CancellationTokenRegistration
- CancellationTokenSource
- Continuation
- ExecutorException
- Task
- TaskCompletionSource
- UnobservedTaskException
- AccessTokenTracker
- AuthenticationTokenTracker
- CustomTabActivity
- CustomTabMainActivity
- FacebookActivity
- FacebookAuthorizationException
- FacebookButtonBase
- FacebookCallback
- FacebookDialog
- FacebookDialogException
- LoginStatusCallback
- WebDialog
- AccessToken
- AccessTokenManager
- AccessTokenSource
- AuthenticationToken
- AuthenticationTokenCache
- AuthenticationTokenClaims
- AuthenticationTokenHeader
- AuthenticationTokenManager
- CallbackManager
- CurrentAccessTokenExpirationBroadcastReceiver
- FacebookBroadcastReceiver
- FacebookContentProvider
- FacebookException
- FacebookGraphResponseException
- FacebookOperationCanceledException
- FacebookRequestError
- FacebookSdk
- FacebookSdkNotInitializedException
- FacebookServiceException
- GraphRequest
- GraphRequestAsyncTask
- GraphRequestBatch
- GraphResponse
- HttpMethod
- LoggingBehavior
- Profile
- ProfileCache
- ProfileManager
- ProfileTracker
- ProgressNoopOutputStream
- ProgressOutputStream
- RequestProgress
- Common
- DeviceRequestsHelper
- EndToEndDumper
- CodeChallengeMethod
- CustomTabLoginMethodHandler
- CustomTabPrefetchHelper
- DeviceAuthDialog
- DeviceAuthMethodHandler
- GetTokenLoginMethodHandler
- KatanaProxyLoginMethodHandler
- LoginBehavior
- LoginClient
- LoginConfiguration
- LoginFragment
- LoginManager
- LoginMethodHandler
- LoginResult
- NativeAppLoginMethodHandler
- NonceUtil
- WebLoginMethodHandler
- WebViewLoginMethodHandler
- DefaultAudience
- LoginTargetApp
- DeviceLoginManager
- Login
- AppGroupCreationContent
- CameraEffectArguments
- CameraEffectTextures
- GameRequestContent
- ShareCameraEffectContent
- ShareContent
- ShareHashtag
- ShareLinkContent
- ShareMedia
- ShareMediaContent
- ShareMessengerActionButton
- ShareMessengerURLActionButton
- ShareModel
- ShareModelBuilder
- SharePhoto
- SharePhotoContent
- ShareStoryContent
- ShareVideo
- ShareVideoContent
- AccessTokenAppIdPair
- AppEvent
- AppEventsConstants
- AppEventsLogger
- AppEventsManager
- FlushResult
- InternalAppEventsLogger
- UserDataStore
- MetadataIndexer
- MetadataRule
- SettingsAPIFields
- AppEventsCAPIManager
- CustomEventField
- AppEventType
- AppEventUserAndAppDataField
- ConversionsAPISection
- ConversionsAPICustomEventField
- ConversionsAPIUserAndAppDataField
- ConversionsAPIEventName
- OtherEventConstants
- AppEventsConversionsAPITransformer
- AppEventsConversionsAPITransformerWebRequests
- CodelessLoggingEventListener
- CodelessManager
- RCTCodelessLoggingEventListener
- ViewIndexer
- Constants
- EventBinding
- ParameterComponent
- PathComponent
- SensitiveUserDataUtils
- UnityReflection
- ViewHierarchy
- EventDeactivationManager
- InAppPurchaseActivityLifecycleTracker
- InAppPurchaseAutoLogger
- InAppPurchaseBillingClientWrapper
- InAppPurchaseEventManager
- InAppPurchaseLoggerManager
- InAppPurchaseManager
- InAppPurchaseSkuDetailsWrapper
- InAppPurchaseUtils
- IntegrityManager
- ActivityLifecycleTracker
- AppEventUtility
- AppEventsLoggerUtility
- AutomaticAnalyticsLogger
- Constants
- FileDownloadTask
- ViewHierarchyConstants
- MTensor
- Model
- ModelManager
- Utils
- OnDeviceProcessingManager
- RemoteServiceWrapper
- RestrictiveDataManager
- SuggestedEventsManager
- ViewOnClickListener
- Core
- GateKeeper
- GateKeeperRuntimeCache
- ExceptionAnalyzer
- InstrumentData
- InstrumentManager
- InstrumentUtility
- ANRDetector
- ANRHandler
- CrashHandler
- AutoHandleExceptions
- CrashShieldHandler
- NoAutoExceptionHandling
- ErrorReportData
- ErrorReportHandler
- ThreadCheckHandler
- Excuse
- ExcusesForDesignViolations
- CertificateUtil
- OidcSecurityUtil
- DeviceLoginButton
- LoginButton
- ProfilePictureView
- ToolTipPopup
- All
public final class AppEventsLogger
The AppEventsLogger class allows the developer to log various types of events back to Facebook. In order to log events, the app must create an instance of this class via a .newLogger method, and then call the various "log" methods off of that.
This client-side event logging is then available through Facebook App Insights and for use with Facebook Ads conversion tracking and optimization.
The AppEventsLogger class has a few related roles:
- Logging predefined and application-defined events to Facebook App Insights with a numeric value to sum across a large number of events, and an optional set of key/value parameters that define "segments" for this event (e.g., 'purchaserStatus' : 'frequent', or 'gamerLevel' : 'intermediate'). These events may also be used for ads conversion tracking, optimization, and other ads related targeting in the future.
- Methods that control the way in which events are flushed out to the Facebook servers.
Here are some important characteristics of the logging mechanism provided by AppEventsLogger:
- Events are not sent immediately when logged. They're cached and flushed out to the Facebook servers in a number of situations:
- when an event count threshold is passed (currently 100 logged events).
- when a time threshold is passed (currently 15 seconds).
- when an app has gone to background and is then brought back to the foreground.
- Events will be accumulated when the app is in a disconnected state, and sent when the connection is restored and one of the above 'flush' conditions are met.
- The AppEventsLogger class is intended to be used from the thread it was created on. Multiple AppEventsLoggers may be created on other threads if desired.
- The developer can call the setFlushBehavior method to force the flushing of events to only occur on an explicit call to the
flush
method. - The developer can turn on console debug output for event logging and flushing to the server by calling FacebookSdk.addLoggingBehavior(LoggingBehavior.APP_EVENTS);
Some things to note when logging events:
- There is a limit on the number of unique event names an app can use, on the order of 1000.
- There is a limit to the number of unique parameter names in the provided parameters that can be used per event, on the order of 25. This is not just for an individual call, but for all invocations for that eventName.
- Event names and parameter names must be between 2 and 40 characters, and must consist of alphanumeric characters, _, -, or spaces.
- The length of each parameter value can be no more than on the order of 100 characters.
Nested Class Summary
Modifier and Type | Class | Description |
---|---|---|
public enum | AppEventsLogger.FlushBehavior | Controls when an AppEventsLogger sends log events to the server |
public enum | AppEventsLogger.ProductAvailability | Product availability for Product Catalog product item update |
public enum | AppEventsLogger.ProductCondition | Product condition for Product Catalog product item update |
public class | AppEventsLogger.Companion |
Method Summary
Modifier and Type | Method | Description |
---|---|---|
final String | getApplicationId() | |
final Unit | logEvent(String eventName) | Log an app event with the specified name. |
final Unit | logEvent(String eventName, Double valueToSum) | Log an app event with the specified name and the supplied value. |
final Unit | logEvent(String eventName, Bundle parameters) | Log an app event with the specified name and set of parameters. |
final Unit | logEvent(String eventName, Double valueToSum, Bundle parameters) | Log an app event with the specified name, supplied value, and set of parameters. |
final Unit | logPurchase(BigDecimal purchaseAmount, Currency currency) | Logs a purchase event with Facebook, in the specified amount and with the specified currency. |
final Unit | logPurchase(BigDecimal purchaseAmount, Currency currency, Bundle parameters) | Logs a purchase event with Facebook explicitly, in the specified amount and with the specified currency. |
final Unit | logPushNotificationOpen(Bundle payload) | Logs an app event that tracks that the application was open via Push Notification. |
final Unit | logPushNotificationOpen(Bundle payload, String action) | Logs an app event that tracks that the application was open via Push Notification. |
final Unit | logProductItem(String itemID, AppEventsLogger.ProductAvailability availability, AppEventsLogger.ProductCondition condition, String description, String imageLink, String link, String title, BigDecimal priceAmount, Currency currency, String gtin, String mpn, String brand, Bundle parameters) | Uploads product catalog product item as an app event. |
final Unit | flush() | Explicitly flush any stored events to the server. |
final Boolean | isValidForAccessToken(AccessToken accessToken) | Determines if the logger is valid for the given access token. |
Method Detail
getApplicationId
final StringgetApplicationId()
logEvent
final UnitlogEvent(String eventName)
Log an app event with the specified name.
Parameters:
eventName
- eventName used to denote the event.logEvent
final UnitlogEvent(String eventName, Double valueToSum)
Log an app event with the specified name and the supplied value.
Parameters:
eventName
- eventName used to denote the event.valueToSum
- a value to associate with the event which will be summed up in Insights for across all instances of the event, so that average values can be determined, etc.logEvent
final UnitlogEvent(String eventName, Bundle parameters)
Log an app event with the specified name and set of parameters.
Parameters:
eventName
- eventName used to denote the event.parameters
- A Bundle of parameters to log with the event.logEvent
final UnitlogEvent(String eventName, Double valueToSum, Bundle parameters)
Log an app event with the specified name, supplied value, and set of parameters.
Parameters:
eventName
- eventName used to denote the event.valueToSum
- a value to associate with the event which will be summed up in Insights for across all instances of the event, so that average values can be determined, etc.parameters
- A Bundle of parameters to log with the event.logPurchase
final UnitlogPurchase(BigDecimal purchaseAmount, Currency currency)
Logs a purchase event with Facebook, in the specified amount and with the specified currency.
Parameters:
purchaseAmount
- Amount of purchase, in the currency specified by the 'currency' parameter.currency
- Currency used to specify the amount.logPurchase
final UnitlogPurchase(BigDecimal purchaseAmount, Currency currency, Bundle parameters)
Logs a purchase event with Facebook explicitly, in the specified amount and with the specified currency. Additional detail about the purchase can be passed in through the parameters bundle.
Parameters:
purchaseAmount
- Amount of purchase, in the currency specified by the 'currency' parameter.currency
- Currency used to specify the amount.parameters
- Arbitrary additional information for describing this event.logPushNotificationOpen
final UnitlogPushNotificationOpen(Bundle payload)
Logs an app event that tracks that the application was open via Push Notification.
Parameters:
payload
- Notification payload received.logPushNotificationOpen
final UnitlogPushNotificationOpen(Bundle payload, String action)
Logs an app event that tracks that the application was open via Push Notification.
Parameters:
payload
- Notification payload received.logProductItem
final UnitlogProductItem(String itemID, AppEventsLogger.ProductAvailability availability, AppEventsLogger.ProductCondition condition, String description, String imageLink, String link, String title, BigDecimal priceAmount, Currency currency, String gtin, String mpn, String brand, Bundle parameters)
Uploads product catalog product item as an app event.
Parameters:
itemID
- Unique ID for the item.availability
- If item is in stock.condition
- Product condition: new, refurbished or used.description
- Short text describing product.imageLink
- Link to item image used in ad.link
- Link to merchant's site where someone can buy the item.title
- Title of item.priceAmount
- Amount of purchase, in the currency specified by the 'currency' parameter.currency
- Currency used to specify the amount.gtin
- Global Trade Item Number including UPC, EAN, JAN and ISBNmpn
- Unique manufacture ID for productbrand
- Name of the brand Note: Either gtin, mpn or brand is required.parameters
- Optional fields for deep link specification.flush
final Unitflush()
Explicitly flush any stored events to the server. Implicit flushes may happen depending on the value of getFlushBehavior. This method allows for explicit, app invoked flushing.
isValidForAccessToken
final BooleanisValidForAccessToken(AccessToken accessToken)
Determines if the logger is valid for the given access token.
Parameters:
accessToken
- The access token to check.