Skip to content

Forwarding Events to Analytics ​

Map the Falcon Android SDK's callbacks and events to your product-analytics tool (Mixpanel, Amplitude, Segment, and similar). There are two kinds of hooks: callbacks you pass to Falcon.execute(...) (scoped to that one call), and events you subscribe to with Falcon.events(layoutId) (scoped to a layout_id). All of them fire on the main thread.

TIP

The callbacks carry no payload (only onError receives an Exception). Attach analytics properties from your own call-site context — the layout_id / view you passed in placement_details, plus anything else you track.

Wiring example ​

The examples below use Mixpanel; any analytics SDK works the same way.

kotlin
Falcon.execute(
    attributes = attributes,
    placement  = FalconPlacement.Inline(falconView),
    onLoad     = { mixpanel.track("falcon_placement_loaded", props) },
    onUnload   = { mixpanel.track("falcon_placement_unloaded", props) },
    onError    = { error ->
        mixpanel.track("falcon_placement_error", props + ("error" to error.toString()))
    },
    onShouldShowLoadingIndicator = { mixpanel.track("falcon_placement_requested", props) },
    onShouldHideLoadingIndicator = { mixpanel.track("falcon_placement_settled", props) },
)

Falcon.events(layoutId) { event ->
    when (event) {
        is FalconEvent.PlacementInteractive ->
            mixpanel.track("falcon_placement_viewable", props)
        is FalconEvent.PlacementCompleted ->
            mixpanel.track("falcon_placement_completed", props)
        is FalconEvent.PlacementFailure ->
            mixpanel.track("falcon_placement_failed", props + ("error" to event.error.toString()))
    }
}

Callbacks (per Falcon.execute call) ​

SDK hookWhen it firesSuggested eventSuggested properties
onShouldShowLoadingIndicatorImmediately when execute begins, before any network activityfalcon_placement_requestedlayout_id, view, sandbox
onLoadOnce, when the placement has rendered content (the web layer signals loaded, or reports a height above 0)falcon_placement_loadedlayout_id, view, sandbox
onShouldHideLoadingIndicatorOnce, when the placement settles: loaded, no offers to show (no-fill), or failedfalcon_placement_settled (optional)layout_id, view. Tip: "settled without loaded" = no-fill, since no-fill fires neither onLoad nor onError
onErrorThe placement cannot be shown (InitNotCalled or PlacementLoadError). At most once per execute call; note it can also fire after onLoad if the web layer reports a late errorfalcon_placement_errorlayout_id, view, error (string)
onUnloadThe placement finished and was removed from the UI: the inline unit completed and collapsedfalcon_placement_unloadedlayout_id, view

Events (per layout_id, via Falcon.events) ​

SDK eventWhen it firesSuggested eventSuggested properties
PlacementInteractiveMore than 50% of the placement has been visible for at least 1 second. At most once per executefalcon_placement_viewablelayout_id
PlacementCompletedThe user engaged with the placement and it was removed from the UI (fires together with onUnload)falcon_placement_completedlayout_id
PlacementFailureThe placement failed to load; carries the error (fires together with onError)falcon_placement_failedlayout_id, error (string)

There is no PlacementClosed — what to use for a "close" event ​

Falcon's event stream has three cases. There is deliberately no PlacementClosed:

  • Inline (embedded) unit: it sits in your layout and cannot be dismissed by the user — there is nothing to close, so an ad-closed analytics event has no source for the inline unit. The user simply scrolls past it.
  • Overlay (full-screen) unit: available on iOS today and planned for the Android SDK. Its dismissal is observable — it surfaces as onUnload and PlacementCompleted. When the overlay reaches Android, map an analytics "close" event from onUnload on your overlay execute call.

Avoiding double counting ​

Two pairs fire together by design: onUnload + PlacementCompleted, and onError + PlacementFailure. Forward one side of each pair to your analytics tool (we suggest the events stream for completion/failure, callbacks for load/settle), or you will count those moments twice.

Include on every Falcon event you forward: layout_id, view, sandbox (bool), sdk_platform: "Android", and your own session/user ids. For the SDK version, forward the dependency version you ship (us.falconlabs:falcon:<version>).