Guide
How to trigger an in-app survey from an Amplitude event
Your Amplitude events already mark the moments worth asking about. Here's how to turn one of them into the trigger for an in-app survey, with no new tracking.
Add an Amplitude plugin from your survey SDK to the Amplitude instance in your app, then create a survey whose trigger is the event name, like checkout_completed. Every event you track passes through the plugin unchanged, and when one matches a survey's trigger (and the user passes your targeting, sampling and frequency rules) the survey shows. With MicroSurveys that's two lines of code on iOS, Android or React Native, set up once.
Why trigger surveys from Amplitude events
The best time to ask about an experience is right after it happens, and your Amplitude events already record exactly when that is. Triggering on them gives you three things:
- No new tracking. You don't add a second analytics call for every survey. The event your team already named, like
checkout_completedorplant_care_viewed, is the trigger. - The right people. Only users who just did the thing are asked about it, so answers are specific.
- Changes without a release. Picking a different event or adding a property filter happens in the survey tool, not in your app's code.
Most survey tools send responses into Amplitude. Fewer can use an Amplitude event as the trigger itself, which is the part that matters for timing.
How it works
Amplitude's SDKs let you add plugins that see every event your app tracks. A survey SDK can register an enrichment plugin that reads each event, checks it against your active surveys, and returns the event unmodified, so your analytics data doesn't change.
- The survey SDK downloads your active surveys and their triggers when the app starts, and caches them on the device.
- Each tracked event is matched against the triggers on the device, with no network round-trip, so it works offline.
- When a trigger matches, the SDK checks the rest of the rules (audience, sample, how often this person has been asked) and shows the survey, optionally after a short delay.
The plugin also reads Amplitude's user id, device id and user properties, so the same identity and properties you use in Amplitude work for targeting surveys.
Set it up with MicroSurveys
Create a project in MicroSurveys, connect Amplitude so your event names show up in the survey builder, and copy the project's SDK key. Then add the plugin where you set up Amplitude in your app:
iOS (Swift)
import MicroSurveysSDK
import AmplitudeSwift
let ms = MicroSurveysSDK(apiKey: "ms_live_xxx")
amplitude.add(plugin: ms.amplitudePlugin()) // events pass through unchanged
ms.start()Android (Kotlin)
val microSurveys = MicroSurveys(this, apiKey = "ms_live_xxx")
amplitude.add(microSurveys.amplitudePlugin())
microSurveys.start()React Native and Expo
import { add, init } from "@amplitude/analytics-react-native";
import { MicroSurveys } from "@microsurveysai/react-native";
export const ms = new MicroSurveys({ apiKey: "ms_live_xxx" });
init("AMPLITUDE_API_KEY");
add(ms.amplitudePlugin());On the web, call track() from the React SDK next to your Amplitude call. Full setup per platform is in the docs: iOS, Android, React Native, Web.
Create the survey and its trigger
In the survey builder, write your question, then set the trigger to the Amplitude event. A few options make it precise:
- Property match. Fire only when the event's properties match, like
checkout_completedwherepayment_methodisapple_pay. - Sequences. Fire when events happen in order within a time window, like
care_guide_viewedthenplant_added_to_cartwithin 30 minutes. - Warmup and repeat. Skip the first few times (ask on the third order, not the first), or fire on every Nth time.
- Delay. Wait a few seconds after the event so the survey doesn't interrupt a confirmation screen.
- Audience, sample and cap. Target by Amplitude user properties, show it to a percentage of users, and cap how often anyone is asked.
Publish the survey and it reaches devices on their next config refresh, with no app release. The details are in Concepts.
Events your backend sends
Some moments are tracked by your server, not the app: an order delivered, a refund issued. The app never sees those events, so a plugin can't react to them. MicroSurveys handles this with Amplitude's Webhook destination: Amplitude streams the selected backend events to MicroSurveys, and the user's app picks them up the next time it opens (or within a minute or two if it's open) and triggers surveys as if it had tracked them. It needs an Amplitude plan with webhooks; see server events.
Examples worth starting with
Examples from Juniper, a plant-delivery app:
| Event | Question | Rule |
|---|---|---|
checkout_completed | “How easy was checkout?” (CES) | 20% of users, at most once a month |
order_delivered (backend) | “How did your plants arrive?” (stars) | Next app open after delivery |
care_guide_viewed | “Did this answer your question?” (thumbs) | Third view onward |
subscription_cancelled | “What's the main reason?” (choice) | Everyone, once |
Questions
No. It's an enrichment plugin that reads each event and returns it unmodified. Your Amplitude data stays exactly as it was.
Connecting it imports your event and property names so you can pick them from a list (this uses Amplitude's Taxonomy API, available on Growth and Enterprise plans). On other plans you type the event names; matching happens on names at runtime either way.
Yes. Call track("event_name") from the SDK wherever the moment happens. It feeds the same trigger engine, and you can use it alongside the Amplitude plugin.
Not directly. Target by user properties instead: the plugin reads the properties you set with Amplitude's identify(), and a survey's audience can require them.
Ask your first question this week.
Free for 1,000 responses a month per project. No card, no demo call.
