af_ prefixed events map automatically to Meta and TikTok conversion events based on your dashboard partner configuration. Custom events appear only in AppsFlyer for funnel and retention analysis.
event_values must always be a JSON stringified and URI encoded object. Always use encodeURIComponent(JSON.stringify(...)). Event names are case-sensitive, lowercase alphanumeric characters and underscores only. There is a limit of 300 unique event names per day.Installation
- Bundle
- CDN
The log_event command
Fire any in-app event by passing an event name and a URI-encoded JSON object of values. Pass{} when there are no values.
string
required
A standard
af_* event or your own custom name. Lowercase alphanumeric and underscores only, case-sensitive.string
required
A URL-encoded JSON object of event parameters. Wrap with
encodeURIComponent(JSON.stringify(...)). Keep values flat: strings, numbers, and booleans.Standard AF Events
These events use theaf_ prefix and map automatically to Meta and TikTok conversion events. Use them for any action you want to optimize ad campaigns against.
af_complete_registration
Records when a user completes sign up.string
Sign up method used, e.g.
"email", "facebook", "google", "apple".af_login
Records when a user logs in.string
Login method used, e.g.
"email", "facebook", "google", "apple".af_purchase
Records a purchase and associates revenue. The most important event for ROAS optimization.number
required
Total purchase amount, counted as real revenue in AppsFlyer. No commas, currency signs, or text. Up to 5 decimal places. Use negative values for refunds.
string
required
3-character ISO 4217 code, e.g.
"USD", "EUR", "AED". Defaults to "USD" if omitted.string
ID of the purchased item or product, e.g.
"pro_plan", "sku_123".string
Category of the purchased item, e.g.
"subscription", "course", "item".number
Number of items purchased.
string
Your internal order ID, used for deduplication.
af_start_trial
Records the start of a free trial.number
Price of the trial. Use
af_price, not af_revenue. af_price is not counted as revenue and is the correct parameter for Meta’s StartTrial mapping.string
3-character ISO 4217 code. Defaults to
"USD" if omitted.af_subscribe
Records a paid subscription purchase.number
Subscription price per period. Not counted as revenue. Add
af_revenue if you also want to record this as revenue in AppsFlyer.string
3-character ISO 4217 code. Defaults to
"USD" if omitted.string
ID of the subscription plan, e.g.
"pro_monthly", "annual_plan".af_add_to_cart
Records when a user adds an item to their cart.string
ID of the item added to cart.
string
Category of the item.
number
Price of the individual item. Not counted as revenue.
string
3-character ISO 4217 code. Defaults to
"USD" if omitted.number
Quantity added to cart.
af_initiated_checkout
Records when a user begins the checkout flow.number
Total cart value at checkout. Counted as revenue if included.
string
3-character ISO 4217 code. Defaults to
"USD" if omitted.number
Total number of items in the cart.
string
Identifier for the checkout session or cart.
af_content_view
Records when a user views a piece of content.string
ID of the content viewed, e.g. a product ID, profile ID, or article ID.
string
Category of the content, e.g.
"product", "article", "collection".number
Price associated with the content if applicable.
string
3-character ISO 4217 code. Defaults to
"USD" if omitted.af_search
Records a search event.string
The search query entered by the user.
af_share
Records when a user shares content.string
Platform shared to, e.g.
"instagram", "whatsapp", "twitter".af_invite
Records when a user sends an invite or referral.string
Channel the invite was sent through, e.g.
"sms", "email", "whatsapp".af_tutorial_completion
Records when a user completes a tutorial or onboarding step.boolean
Whether the tutorial was completed successfully.
string
Name or identifier of the tutorial step.
af_level_achieved
Records when a user reaches a new level.number
The level number achieved.
Custom Events
Custom events do not map to Meta or TikTok automatically, but appear in your AppsFlyer dashboard for funnel and retention analysis. Name them using lowercase alphanumeric characters and underscores, and keep the parameter set stable so dashboards stay queryable.To postback a custom event to Meta or TikTok, map it manually in Configuration > Integrated Partners > [Partner] > In-App Events. Standard
af_ events are mapped automatically.Frequently Asked Questions
What is the difference between af_price and af_revenue?
What is the difference between af_price and af_revenue?
af_revenue is counted as real revenue in AppsFlyer and reported in your dashboard and raw data. Use it for actual purchases. af_price is a monetary value that is not counted as revenue. Use it for events like af_add_to_cart or af_start_trial where you want to pass a price but not record revenue. For Meta’s StartTrial mapping specifically, use af_price, not af_revenue.Do I need to map events in the AppsFlyer dashboard?
Do I need to map events in the AppsFlyer dashboard?
For standard
af_ events, AppsFlyer maps them automatically to Meta and TikTok. For custom events you need to add them manually in Configuration > Integrated Partners > [Partner] > In-App Events if you want them postbacked to partners.Can I send multiple items in a single purchase event?
Can I send multiple items in a single purchase event?
Yes. Use
af_content_list with a stringified array of IDs and af_content with a stringified array of objects, each containing id and quantity. Do not include af_content_id in the same event when using af_content_list.How do I record a refund or cancellation?
How do I record a refund or cancellation?
Fire an event with a negative
af_revenue value and a custom event name like cancel_purchase:Do events work offline?
Do events work offline?
Yes. The native SDK queues events on the device and sends them when connectivity returns.
Do I need to identify the user first?
Do I need to identify the user first?
No, but events logged after
set_user_id are tied to your internal user ID in raw-data exports. Identify as early as you can, see User Identity.Resources
NPM Package
despia-native