AppsFlyer Rich In-App Events - Android

AppsFlyer’s rich in-app events provide advertisers with the ability to track any post-install event and attribute it to a media source and campaign.

An in-app event is comprised of an event name and event parameters (see below for the list of recommended event and parameter names). 

Syntax:

public static void trackEvent(Context context, String eventName, Map eventValues)
  • context - use getApplicationContext()
  • eventName - any string to define the event name. You can find a list of recommended constant event names in Appendix A.
  • eventValues - a map of event parameters that comprise a rich event.

Example 1: Level Achieved In-App Event

Map<String, Object> eventValue = new HashMap<String, Object>();
eventValue.put(AFInAppEventParameterName.LEVEL,9);
eventValue.put(AFInAppEventParameterName.SCORE,100);
AppsFlyerLib.trackEvent(content,AFInAppEventType.LEVEL_ACHIEVED,eventValue);

This generates an event of type “af_level_achieved” with the following event values:

{af_level: 9, af_score: 100}

Example 2: Purchase Event

Map<String, Object> eventValue = new HashMap<String, Object>();
eventValue.put(AFInAppEventParameterName.REVENUE,200);
eventValue.put(AFInAppEventParameterName.CONTENT_TYPE,"category_a");
eventValue.put(AFInAppEventParameterName.CONTENT_ID,"1234567");
eventValue.put(AFInAppEventParameterName.CURRENCY,"USD");
AppsFlyerLib.trackEvent(content,AFInAppEventType.PURCHASE,eventValue);

This generates an event of type “af_purchase” with the following event values:

{af_content_id: “1234567”, af_content_type: “category_a”, af_revenue: 200, af_currency: “USD”}

The purchase event above contains a $200 revenue, appearing as revenue in the dashboard.

Example 3:  Complex In-App Event

The following is an example of a complex In-App Event that can be sent.

{"af_revenue":"50.87","af_currency":"USD","af_receipt_id":"57601333","product":
[{"af_content_id":"1164_8186","af_price":"8.97","af_quantity":"1"},
{"af_content_id":"1164_8186","af_price":"8.97","af_quantity":"1"},
{"af_content_id":"1164_8186","af_price":"8.97","af_quantity":"1"},
{"af_content_id":"1177_8185","af_price":"8.97","af_quantity":"1"},
{"af_content_id":"0153_9077","af_price":"14.99","af_quantity":"1"}]}

In-App Event Types

The following in-app events are defined as part of the AFInAppEventType interface and are recommended: 

  • Purchase - Used to track purchase events (and associate revenue to them)
  • Travel Booking - Used to track travel booking events (and associate revenue to them)

 

Was this article helpful?
2 out of 2 found this helpful
Have more questions? Submit a request
Powered by Zendesk