Docs
SDK

Auto placements

Let placements show themselves on page load, scroll, exit intent, app open or an app event, with one call.

Placements that have a trigger in the dashboard (see Screen and display) show themselves. Call startAutoPlacements once per page (web) or once after configure (mobile).

function startAutoPlacements(options?: AutoPlacementsOptions): AutoPlacementsHandle;
UIKit.configure({ apiKey: 'pk_...' });

const auto = UIKit.startAutoPlacements({
  products: { monthly: { price: 9.99, currency: 'USD', period: 'month' } },
  onPurchase: async ({ packageId }) => startCheckout(packageId),
  onAction: ({ actionId }) => handleAction(actionId),
  onResult: ({ placement, result }) => console.log(placement, result),
});

A placement has one trigger: a website trigger or an app trigger. A website never fires app triggers and an app never fires page triggers.

Options

Auto placements take every present option except the source and the display ones (the placement sets the format). Options are read when a screen opens, so prices you load later are used. On iOS and Android the options function runs each time a placement is about to show, so each placement can have its own handlers; on web, React Native and Flutter one set applies to all.

OptionWhat it does
onResultCalled with the placement key and a PurchaseResult when a screen shown by a trigger finishes, or targeting chose to show nothing.

Load failures go to onError; they are never thrown.

Stopping and restarting

Web: startAutoPlacements returns a handle. refresh() re-arms the triggers for the current page (for example after a route change the SDK did not notice). stop() removes every trigger and the launcher button; a screen already open stays open. Calling it again while one is active returns the same handle. Without a window (server rendering) it returns a handle that does nothing. In React use useAutoPlacements(options) once in your root layout (React).

Mobile: Miniwall.stopAutoPlacements() removes the triggers and forgets queued events (for example on sign-out); call startAutoPlacements to start again. Call startAutoPlacements once: calling it again only replaces the options and the result callback. On React Native, Miniwall.dispose() also removes the native listener. On Android, call it from Application.onCreate, or pass the activity on screen (Miniwall.startAutoPlacements(activity = this, ...)) when you start it later; React Native and Flutter pass it for you.

Triggers

Website triggers

TriggerFires
page_loadWhen the page has loaded (immediately if it already has).
delayAfter seconds seconds.
scrollWhen percent percent of the page has been scrolled. A page that cannot scroll counts as 100%.
exit_intentWhen the pointer leaves through the top of the window. Never on touch-only devices (hover: none).
manualNever by itself.

A trigger may list pages, matched against the path: * matches anything, a trailing / is ignored, and no patterns means every page.

App triggers (ignored on websites)

Trigger in the dashboardFires
When the app opensWhen the app starts and each time it returns to the foreground. On every N th time the app opens limits it to every Nth open (1 to 100; default 1), counted on the device.
After N secondsN seconds (1 to 600) after the app opens.
When the app reports an eventWhen your app calls track with that event name: lowercase letters, digits and underscores, starting with a letter, up to 40 characters.
When my code calls itNever by itself.

The queue

  • One screen at a time. Web: once an automatic screen has opened, the other triggers of that page view are dropped, and a trigger that fires while any screen is open is dropped. Mobile: while a screen is open, app open and after N seconds triggers are dropped; events from track are kept (up to 5, in order) and play one at a time when the screen closes.
  • By priority. If several fire at once, the highest Priority (0 to 100) goes first, then the placement created first. A placement that targeting skips (frequency limit, audience, holdout) lets the next one try.
  • Your own call. Web: calling presentPaywall while an automatic screen is open closes the automatic one with closed. Mobile: you can call present at any time; event triggers that fire meanwhile wait for the screen to close.
  • Web route changes. The SDK watches location.pathname (the popstate event and a check every second). A new path is a new page view: old triggers are removed and new ones armed.
  • Mobile visibility. Only while the app is visible: a delay that runs out in the background shows nothing, and delays count from the latest open. An event reported before the placement list has loaded is kept and played when it arrives.

The list comes from GET /v1/sdk/auto (mobile adds ?platform=ios or android). It leaves out placements with no published screen, placements with a manual trigger and placements whose trigger belongs to the other kind (website or app).

Launcher (web)

A placement whose format is Launcher shows a floating button instead of a screen. The button needs its label, appears when audience and holdout allow, and is one per page; it does not use the page's one screen. Pressing it opens the screen as a popup or a slide-in, hides the button, and brings it back with focus on close. The frequency limit is not applied to the button. On mobile a launcher placement opens like a popup from its trigger; there is no floating button.

On this page