Skip to content

Experiences

An experience is what one site shows for one outcome of one feature: a modal, a banner, a slide-in or a block in the page. You describe it in the console, EdgeKit generates it, and the browser client draws it when a decision returns that outcome. Other platforms use the same word for the rules and the design together. In EdgeKit the rules are the feature, and the experience is only what the page shows.

An experience is optional. A decision still returns the outcome’s id and fields, and a page can switch on them and draw its own components, with or without an experience.

  • One per site, feature and outcome id. A feature that returns metered-out on two sites can show a different experience on each. Outcomes that share an id in one feature share the experience.
  • It holds no rules and no experiment arms. To test two designs, return two outcomes from the feature, or put an arm condition on a rule, and give each outcome its own experience. See Experiments.
  • It is deployed with everything else. Saving changes the draft. Your site shows the experience after the next deploy. An edit to an experience adds no feature version, and still appears in the deploy diff. See Stage and deploy a change.

In Revenue › Decision Engine › Experiences, select New experience.

  1. Under What it shows for, pick the Site, the Feature and one of the feature’s outcomes.
  2. Under Generate, write what the site should show in Request, such as “a modal with the offer’s name and a subscribe button, in the site’s colours”. You can attach one image as a reference: PNG, JPEG, WebP or GIF, at most 5 MB.
  3. Pick a Model, then select Generate. The request goes to the model with the feature, the outcome’s fields, the offers those fields name, the meters and experiments the feature reads, and the site’s brand.
  4. Review the preview. It shows the experience at Desktop and Mobile widths over a placeholder article, filled with sample values for the outcome’s fields.
  5. To change it, write what to change in Request and select Update. Each update works on the experience as it stands. No conversation is kept.
  6. Set Display and Trigger, then select Save experience.

Generating never edits a feature, a rule, an outcome or an experiment. When the experience needs a field the outcome does not have, the model says so, and you add the field in Revenue › Decision Engine › Outcomes.

Each Generate and each Update is one AI action on your organization’s usage.

EdgeKit draws the frame: the backdrop, the close button, focus handling and scroll lock. The experience draws only what is inside it. You can switch the display without generating again.

Display Setting What EdgeKit draws around it
Modal none Backdrop, focus trap, scroll lock, close button, closes on Escape
Banner Edge: top or bottom Close button, closes on Escape
Slide-in Corner: one of the four Close button, closes on Escape
Inline Width: Column or Full width Nothing. It is part of the page

One modal shows at a time. When several features return a modal, they open one after another, in the order your page asked for the features. Banners, slide-ins and inline experiences do not wait for each other.

A new decision for a feature replaces the experience that feature is showing.

An inline experience is drawn where your page puts this element, with the feature’s name:

<div data-edgekit-experience="paywall"></div>

On a page with no anchor for the feature, the experience is not shown. It never falls back to a modal. An inline experience arrives after the page has painted, so reserve the anchor’s height in your own CSS if the shift matters.

Column is the anchor’s own width. Full width runs from one edge of the viewport to the other, wherever the anchor sits. An ancestor with overflow: hidden still clips it.

For a modal, a banner and a slide-in, Modal dismiss sets how long the experience stays away after the user closes it:

  • Page: until the page asks for the decision again. This is the default.
  • Session: for the browser session.
  • For good: in that browser, until its storage is cleared.
  • Not allowed: no close button, and Escape and the backdrop do nothing. The experience must offer its own way forward.

The choice is remembered in the user’s browser, for that feature and outcome, so editing the experience does not bring it back. An outcome preview ignores it, so you always see the experience you are previewing.

Trigger Setting When the experience shows
At once none As soon as the decision arrives
After a delay Seconds, 1 to 600 That long after the decision arrives
On scroll Percent scrolled, 1 to 100 When the user has scrolled that far down the page
On exit intent none When the pointer leaves the page through its top edge. Never on a touch screen

A meter counts when your page asks for the decision, not when the experience shows. A trigger that never fires still uses one read of the allowance. Use At once on a feature whose meter must match what users saw.

How often a user sees an experience is a meter on the feature. How long a closed one stays closed is Modal dismiss.

Turn them on in the browser client:

import { createClient } from '@edgekitcloud/client-browser';
const edgekit = createClient({
siteId: 'site_example',
experiences: true,
tracker, // optional: where the experience events go
onExperienceError: ({ feature, reason }) => drawMyOwn(feature),
onExperienceDismiss: ({ feature, remembered }) => drawMyOwn(feature),
});
await edgekit.decide('paywall');
  • Every decision that carries an experience is shown. A page pays nothing for the option until a decision carries one: the code that draws experiences loads only then.
  • Nothing about an experience can make decide throw or reject.
  • onExperienceError is called when an experience cannot show. onExperienceDismiss is called when the user closes one, and when one is skipped because they closed it before (remembered is true). Draw your own fallback in both, so a gated page always has a call to action. Neither is called while a trigger is still waiting.
  • A site that decides only on its server still needs the browser client on the page to show an experience.

See BrowserClientOptions.

Behind the site proxy, experiences show with no code on your page. An inline experience takes the place of the proxy’s built-in panel, and the panel is drawn instead if the experience fails. Any other display is drawn beside the panel, never in its place, so a closed modal still leaves the gated article with a call to action.

A decision whose outcome has an experience on that site carries one more field, experience. It names the module’s URL on your own domain, under /edgekit/x/, and the display, the trigger and the site’s brand. See The response. A client that does not know the field ignores it, and a decision with no experience has no such field. Decide never returns HTML.

When you pass a tracker, the browser client sends four events, each with the feature, the outcome id and the module’s hash:

Event Sent when Also carries
experience_view The experience is shown
experience_click The experience reports an action action, the name the experience gave it
experience_dismiss The user closes it
experience_error It could not be shown reason

reason is one of no_anchor, load_failed, mount_threw, contract or unsupported. Treat a value you do not know as a failure.

With no tracker, none is sent. A view is not an experiment exposure: the two are counted separately, and neither is worked out from the other.

The console preview runs the experience in isolation. To see it on your real pages, save it, then select the eye in the preview’s browser bar. It stages the saved draft and opens the experience’s site in a new tab for 30 minutes, with the feature answering the experience’s outcome. Open a page that asks for that feature. For an inline experience, the page must also hold the anchor.

This is an outcome preview: only your browser gets it, and the pinned feature counts on no meter. It needs the Stage permission.

What the console generates is one JavaScript module, and you can write or edit it by hand under Module source:

export default function mount(root, ctx) {
const button = document.createElement('button');
button.textContent = ctx.value.label;
button.addEventListener('click', () => {
ctx.track('subscribe');
location.href = ctx.value.url;
});
root.append(button);
return () => button.remove(); // unmount
}

root is the experience’s shadow root. ctx holds:

Property What it is
feature, outcome The feature’s name and the outcome’s id
value The outcome’s fields
meters The decision’s meters, or null when no rule read one. Treat a missing one as null
display The display it is drawn in. Lay out for each kind, because the display can change without a new module
brand The site’s logo, colours and font, or null. Read it here, so a brand edit restyles the experience
client The page’s browser client, for sign-in or a newsletter signup. null behind the site proxy
close() Closes the experience, at every Modal dismiss setting
track(name) Sends experience_click with name as its action, at most 64 characters

The types are ExperienceMount and ExperienceContext.

Saving refuses a module that:

  • is larger than 64 KB, or does not parse;
  • has no default export, or exports an async function or a generator: mount returns its unmount directly;
  • uses import, import(), eval, Function, document.cookie or document.write.

Checkout links out. An experience cannot take a payment. Its button sends the user to your subscribe page with the offer and its token, as ?offer=<offer id>&token=<token>. See Checkout.

The module is your organization’s own code, running on your own site.

  • Its styles are isolated. No selector crosses the shadow root in either direction, so your page’s CSS does not restyle the experience and the experience does not restyle your page. Inherited custom properties (--*) and the root font size do reach it, so a module sets its own properties and sizes in px or em.
  • Its script is not isolated. It runs in the page, and can reach document, the page’s globals and any cookie that is not HttpOnly, as a tag from a tag manager can. Review a generated module as you would any script you add to your site.
  • It needs no change to your Content Security Policy. The module is served from your own domain, which script-src 'self' allows, and its styles are constructed stylesheets, which style-src does not govern.
  • A module that throws is caught. The experience is not shown, experience_error is sent with mount_threw, and onExperienceError is called.

The console’s own preview runs the module in a sandboxed frame, never on the console’s origin.

With config as code, an experience is an entry in experiences.yaml, keyed by site domain, feature and outcome id, with its module in a file under experiences/:

experiences.yaml
www.example.com/paywall/metered-out:
display: { kind: inline, width: bleed }
trigger: { kind: delay, seconds: 5 }
module: experiences/www.example.com/paywall/metered-out.js

A bare kind is shorthand: display: banner is a banner on the bottom edge, and display: slide-in slides in from the bottom right. Applying the files runs the same checks as saving in the console.

Owner, Admin and Developer can read, generate, edit and delete experiences. Editor and Member cannot open them. Deploying needs the Deploy permission. See Who can change it.

edgekit.ai