The rest of this page covers Console-managed rendering.
Prerequisites
- API key and Project ID from the Auxia Console.
- Project Website URL set in your project settings in the Auxia Console. The Console uses it to open your site for picking placements and previewing treatments.
1. Install
Add the SDK script to every page where treatments may appear:2. Initialize
3. Enable Console-managed rendering for your project
Ask your Auxia contact to enable Console-managed rendering for your project. Once enabled, the Surfaces list under Configuration > UI Layout in the Auxia Console shows an SDK status column, which shows the surfaces it serves.4. Set up surfaces and treatments
In the Auxia Console:- Create a surface and pick where it appears by selecting an element on your live site.
- Choose the pages it applies to and how it is inserted relative to that element.
- Choose a Layout for the surface.
- Set up treatments, and preview them on your site before publishing.
Page paths
A page path is matched against the page’s whole URL path. The domain, query string and fragment are not part of it./jobs/ matches only that exact page, and /jobs without the trailing slash is a different page.
Three wildcards widen a path:
For example,
/*/articles/*/ matches these paths as follows:
To cover a path and everything below it, use
**. /jobs/** matches /jobs/, /jobs/index.html and /jobs/tokyo/123.
When you select an element on your page, the Console lets you choose how widely the path applies. This page only keeps the exact path, Matching pattern replaces an ID-like segment with *, and All pages below this path covers the folder that holds the page, for example /jobs/** for /jobs/index.html.
Injection positions
To keep your own content in a
REPLACE element for when Auxia doesn’t render, see Fallback content.
Using Google Tag Manager
You can add the SDK through a Custom HTML tag instead of editing your site’s code. Create a Custom HTML tag that loads the SDK script and calls Auxia.initialize() once the script has loaded, pass the user ID in from a GTM variable (for example, a Data Layer Variable), and set the tag to fire on every page where treatments may appear, only after the user ID is available.How the SDK behaves on your site
- It loads your surface configuration from Auxia and caches it in the browser.
- On each page, it renders treatments only on the surfaces whose page paths match, waiting for elements that load late.
- Views, clicks and dismissals are recorded automatically. See Interaction tracking.
- Single-page app navigation is handled: surfaces are removed and re-rendered as the path changes.
- Failures are contained. If anything goes wrong, the page is left untouched, no error is thrown into your code, and first paint is never blocked.
Interaction tracking
A view is recorded automatically once at least half of the treatment has been visible for one second. Clicks and dismissals are recorded only on elements in the Layout or Design template that carrydata-aux-button-name:
data-aux-button-name are not recorded.
Check that interactions reach Auxia
You can check in your browser that an interaction was sent, and in the Auxia Console that Auxia stored it against the right treatment. In your browser. Open DevTools, go to the Network tab and filter byLogTreatmentInteraction. Each recorded view, click or dismissal is one POST request to /v1/LogTreatmentInteraction, and a 200 status means Auxia accepted it. The request payload contains:
The SDK does not report a rejected request in the browser console, so check the status in the Network tab.
In the Auxia Console. Open Treatments & Journeys > QA & Testing > Recent Responses, choose the surface, and click Refresh. It shows the treatments Auxia returned and the views and clicks recorded for them. See Checking Recent Responses for what the tab shows and the role it needs.
Fallback content
Fallback content is optional. Most surfaces don’t need it:- Default: no fallback. For visitors who should see your existing content, such as the control group or visitors without a treatment, set up a treatment with that content in the Auxia Console. It is tracked like any other treatment, so the control group’s views and clicks stay comparable.
- Use fallback content only when the surface must show something even if Auxia can’t be reached or doesn’t answer in time, such as a landing page’s key visual, or when the element needs real content in the HTML for crawlers.
REPLACE injection position.
What visitors see
The element shows loading content, then exactly one final state:
Visitors never see the fallback replaced by Auxia’s content, or Auxia’s content replaced by the fallback.
Set it up
-
Add the Auxia stylesheet to
<head>, on every page with a fallback. It is the same for every page and every site.- Use a normal
<link>in<head>, before the slot. It has to be in place before first paint: the SDK loads after the page has painted, so only CSS already on the page can keep the fallback hidden until Auxia decides. Don’t add it from a tag manager. - It adds one small request to
auxia.netthat blocks rendering, on each page that links it. - If
auxia.netis unreachable, the fallback shows straight away, together with the loading content. Your page keeps its own content. - If your site can’t load a third-party stylesheet (for example because of its Content Security Policy), you can copy the contents of
auxia.cssinto a<style>in<head>instead. You then need to update that copy yourself when the file changes.
- Use a normal
-
Mark up the element:
data-auxia-slotgoes on the element the surface is placed on.data-auxia-fallbackis your content, shown when Auxia doesn’t render.data-auxia-loading(optional) shows until the final state. Without it, the space stays blank.- Both must be direct children of the slot.
-
In your own CSS, reserve the slot’s size and, optionally, set the deadline:
- Reserve the size (
aspect-ratio,min-heightor a fixed height), so the page doesn’t shift when the final content appears. --auxia-fallback-delayis the deadline, inmsors. The default is3000ms.
- Reserve the size (
-
In the Auxia Console, place the surface on the slot’s selector (for example
.kv) withREPLACE.
Listen for the outcome
Optional. The slot firesauxia:slot-settled when it reaches its final state, and the event bubbles to document:
data-auxia-state.
Things to know
REPLACEonly. With another position, your fallback stays next to Auxia’s content.- Leave the slot’s
displayto the Auxia stylesheet. It stacks the loading and fallback content in one grid cell. Settingdisplayon the slot in your own CSS breaks this. - Keep the loading content light, such as a CSS skeleton. A large loading image can become the page’s Largest Contentful Paint.
- The fallback image always downloads, even when Auxia renders, because hidden images still load. In return, it appears instantly when needed.
- A late response is not shown. Once the deadline passes, the slot keeps the fallback for the rest of the page view.
- A slot added later gets the full deadline. On a client-rendered page, the deadline counts from when the slot appears.
- Single-page apps: a slot that stays on the page across routes keeps its state. Once it has settled on the fallback, it keeps the fallback.
Contextual attributes from your page
Pass context only your page knows, such as a membership tier or a cart value, as contextual attributes, and Auxia uses it to choose and personalize treatments on your Console-managed surfaces.- Pass values known at page load to
initialize({ contextualAttributes }), so the first request carries them. setContextualAttributes(attributes, { scope })merges into what is already set, andnullremoves a key. It sends no request by itself: values go out with the SDK’s next request, or immediately for a placement set to refresh on that attribute.- Values can be a
string,number,booleanorDate. scopeonly matters in a single-page app. Every value is cleared when the page reloads (the SDK starts fresh); with"page", it is also cleared when the URL path changes, while"session"(default) keeps it across route changes.- It throws on an empty or reserved key (any
auxia_*key,user_id,surfacesand a few others), an unsupported value type or an unknownscope.NaN,Infinityand invalidDates are skipped with a console error.
Refresh a placement when an attribute changes
By default, a placement fetches once per page view, so a value set later is used from the next request on. To have a placement fetch again when a specific attribute changes, turn it on for that placement in the Auxia Console (Placement step → Advanced · Refresh on context change), add the attribute, and choose what happens when it changes:- Fill if empty (default): fetch again only while the placement is showing nothing. Content already on the page stays.
- Replace content: fetch again every time the value changes and show the new result. If nothing comes back, the current content stays.
Styling
Surfaces render inside a Shadow DOM, so your page stylesheet does not reach them. Reusing your own class names styles nothing. CSS custom properties do cross the boundary, so tokens defined on the page are readable from inside the surface:Overlays and display timing
Overlay Layouts
With Placement Type set to Overlay, a surface shows over the page instead of at an element; the SDK adds it to the end of<body>. In the Layout step, pick Modal, Bottom bar or Corner panel. For your own backdrop, position or size, or an entrance animation, pick Custom: it starts from a copy of the Layout you had selected.
Show after a delay or a scroll
In the surface’s Placement step, where you pick the element and pages, open When it shows and set either or both. The setting applies to every treatment shown in that surface.- Delay: seconds to wait after the SDK adds the surface to the page.
3shows it 3 seconds later. - Scroll depth: how far down the page the visitor must scroll, in % of the page.
50shows it once they have scrolled halfway. - With both set, it shows once both are met. With neither, it shows right away.
Modal handling
The Modal Layout behaves as a modal dialog. When it appears, keyboard focus moves into it and Tab stays inside. Escape or a click on the backdrop closes it, recordsDISMISSED, and returns focus to where it was.
To get this in a Custom Layout, add role="dialog" to the dialog element: the card, not the backdrop. Don’t add it to bars, corner panels or inline banners, where trapping focus stops keyboard users from reaching the rest of the page.
Entrance animation
When an overlay shows (after any delay or scroll), the SDK setsdata-auxia-revealed on the surface’s host element. In a Custom Layout, start the animation from :host([data-auxia-revealed]):
- Write the final look as the normal style and only the starting state in
@keyframes. The Console preview never sets the attribute, so anything hidden by default stays hidden there. - Animate elements inside the Layout, not
:host: atransformoropacityon the host can break the overlay’s fixed position and stacking.
The Console preview shows treatments right away. It ignores delay and scroll, and doesn’t play the animation or apply modal handling, so check these on your site.
Moving a surface from your own code to the Console
A surface you already render from your own code keeps working as it is. To hand it over to the Console:- Remove its
fetchAndRenderTreatments()orgetTreatments()call. Calls for your other surfaces keep working. - Its container element and
surfaceHtmlElementIdare replaced by a placement picked in the Console. data-aux-*interaction attributes move from your page markup into the Layout and Design templates in the Console.- Contextual attributes are set once with
setContextualAttributes()instead of on each call.
Troubleshooting
If a surface does not render, check that:- The SDK status column appears in the Console. If it does not, Console-managed rendering is not yet enabled for your project.
Auxia.initialize()is called with a non-emptyuserId.- The surface’s page paths match the page you are on.
- The element the surface is placed on exists on the page.
- The surface has a published Layout and at least one live treatment.
<head> and loads, and that the surface uses REPLACE.
If a view or click is not recorded, check that:
- For a click, or a dismissal from a button, the element carries
data-aux-button-name. - For a view, at least half of the treatment stayed visible for one second.
- The
LogTreatmentInteractionrequest returns200. See Check that interactions reach Auxia. - In Recent Responses, the surface and user ID match your test, and the test was within the last 24 hours.