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
Page paths are matched against the whole path./jobs/ matches only that exact page; use /jobs/** to also cover /jobs/index.html and everything below it.
Injection positions
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.
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: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.