Interface: InteractionNamespace
Defined in: interaction/types.ts:17
Methods for triggering and managing on-page interactions.
Access this namespace via allegro.interaction.
Methods
evaluate()
evaluate():
Promise<void>
Defined in: interaction/types.ts:86
Re-run server-side interaction targeting for the current page and render the matches. Safe to call manually — e.g. from a single-page-app router hook after navigation.
Idempotent across calls: interactions rendered by a previous evaluate()
that no longer match are removed before the new matches render, so stale
content from a prior route does not linger.
Runs even when config.interactions is false — that flag only suppresses
the automatic on-load evaluation, not manual calls. No-op in preview mode
and non-browser contexts.
Returns
Promise<void>
Example
// Vue Router
router.afterEach(() => window.allegro.interaction.evaluate());
experiments()
experiments():
Record<string,string|null>
Defined in: interaction/types.ts:93
The visitor's A/B test assignments from the most recent evaluation:
experiment id → variant id, or null when they are not in that test.
Opaque labels, safe to forward to your own analytics.
Returns
Record<string, string | null>
remove()
remove(
slug):void
Defined in: interaction/types.ts:105
Remove an active interaction from the DOM.
Parameters
| Parameter | Type | Description |
|---|---|---|
slug | string | The slug of the interaction to remove. |
Returns
void
Example
allegro.interaction.remove('newsletter-signup');
renderActions()
renderActions(
actions,options?):Promise<void>
Defined in: interaction/types.ts:57
Execute a pre-built set of interaction actions directly.
This is the rendering half of trigger. Use it when you have already constructed the actions array (e.g. from local files in allegro-preview) and want to run them through the real SDK pipeline without fetching from the API.
Parameters
| Parameter | Type | Description |
|---|---|---|
actions | InteractionAction[] | The actions to execute. |
options? | { attribution?: TemplateAttribution; data?: Record<string, unknown>; skipDelays?: boolean; slug?: string; } | - |
options.attribution? | TemplateAttribution | Decision attribution for interactions matched by server-side targeting evaluation. Threaded into template-view tracking events as interaction_id/journey_id for later analysis. Omitted for manually triggered interactions. |
options.data? | Record<string, unknown> | Arbitrary data passed to Alpine template context. |
options.skipDelays? | boolean | When true, skip scroll/time delays. Defaults to auto-detecting magic-link / allegro_token in URL. |
options.slug? | string | Optional slug used for cleanup and Alpine context. |
Returns
Promise<void>
trigger()
trigger(
slug,data?):Promise<InteractionResponse>
Defined in: interaction/types.ts:37
Trigger an interaction by its slug.
Fetches the interaction from the API and executes its configured actions (template injection, CSS, JavaScript, cookies, etc.) on the current page.
Parameters
| Parameter | Type | Description |
|---|---|---|
slug | string | The interaction's unique slug as configured in the dashboard. |
data? | Record<string, unknown> | Arbitrary data passed to the interaction for use in template field values or action logic. |
Returns
Promise<InteractionResponse>
The interaction record returned by the API.
Example
await allegro.interaction.trigger('newsletter-signup');
// With extra data
await allegro.interaction.trigger('welcome-banner', { source: 'homepage' });
ungate()
ungate(
slug):void
Defined in: interaction/types.ts:117
Reveal content that was gated by an interaction.
Parameters
| Parameter | Type | Description |
|---|---|---|
slug | string | The slug of the interaction whose gate should be lifted. |
Returns
void
Example
allegro.interaction.ungate('paywall');