Client-side event logging for specialized application analytics available through Facebook App Insights and for use with Facebook Ads conversion tracking and optimization.
AppEventsLoggerstatic 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
segmentsfor this event (e.g., ‘purchaserStatus’ : ‘frequent’, or ‘gamerLevel’ : ‘intermediate’)
- Logging events to later be used for ads optimization around lifetime value.
- 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
- 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.
AppEventsLoggerclass is thread-safe in that events may be logged from any of the app’s threads.
- The developer can set the
flushBehaviorto force the flushing of events to only occur on an explicit call to the
- The developer can turn on console debug output for event logging and flushing to the server by using the
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 (the keys in the Dictionary) 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.