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.
A standard
af_* event or your own custom name. Lowercase alphanumeric and underscores only, case-sensitive.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.
| Event | When to log it | Maps to |
|---|---|---|
af_complete_registration | Account created | Meta CompleteRegistration, TikTok CompleteRegistration |
af_login | User logs in | Login |
af_purchase | Payment completed | Meta Purchase, TikTok CompletePayment |
af_start_trial | Free trial started | Meta StartTrial, TikTok Subscribe |
af_subscribe | Paid subscription started | Meta Subscribe, TikTok Subscribe |
af_add_to_cart | Item added to cart | Meta AddToCart, TikTok AddToCart |
af_initiated_checkout | Checkout started | Meta InitiateCheckout, TikTok InitiateCheckout |
af_content_view | Product or content page viewed | Meta ViewContent, TikTok ViewContent |
af_search | Search performed | Meta Search, TikTok Search |
af_share | Content shared | AppsFlyer only |
af_invite | Invite or referral sent | AppsFlyer only |
af_tutorial_completion | Onboarding or tutorial finished | Meta CompleteTutorial |
af_level_achieved | Progression milestone | Meta AchieveLevel, TikTok AchieveLevel |
af_complete_registration
Records when a user completes sign up.Sign up method used, e.g.
"email", "facebook", "google", "apple".af_login
Records when a user logs in.Login method used, e.g.
"email", "facebook", "google", "apple".af_purchase
Records a purchase and associates revenue. The most important event for ROAS optimization.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.
3-character ISO 4217 code, e.g.
"USD", "EUR", "AED". Defaults to "USD" if omitted.ID of the purchased item or product, e.g.
"pro_plan", "sku_123".Category of the purchased item, e.g.
"subscription", "course", "item".Number of items purchased.
Your internal order ID, used for deduplication.
af_start_trial
Records the start of a free trial.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.3-character ISO 4217 code. Defaults to
"USD" if omitted.af_subscribe
Records a paid subscription purchase.Subscription price per period. Not counted as revenue. Add
af_revenue if you also want to record this as revenue in AppsFlyer.3-character ISO 4217 code. Defaults to
"USD" if omitted.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.ID of the item added to cart.
Category of the item.
Price of the individual item. Not counted as revenue.
3-character ISO 4217 code. Defaults to
"USD" if omitted.Quantity added to cart.
af_initiated_checkout
Records when a user begins the checkout flow.Total cart value at checkout. Counted as revenue if included.
3-character ISO 4217 code. Defaults to
"USD" if omitted.Total number of items in the cart.
Identifier for the checkout session or cart.
af_content_view
Records when a user views a piece of content.ID of the content viewed, e.g. a product ID, profile ID, or article ID.
Category of the content, e.g.
"product", "article", "collection".Price associated with the content if applicable.
3-character ISO 4217 code. Defaults to
"USD" if omitted.af_search
Records a search event.The search query entered by the user.
af_share
Records when a user shares content.Platform shared to, e.g.
"instagram", "whatsapp", "twitter".af_invite
Records when a user sends an invite or referral.Channel the invite was sent through, e.g.
"sms", "email", "whatsapp".af_tutorial_completion
Records when a user completes a tutorial or onboarding step.Whether the tutorial was completed successfully.
Name or identifier of the tutorial step.
af_level_achieved
Records when a user reaches a new level.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