Interface: InteractionNamespace
Defined in: interaction/types.ts:13
Methods for triggering and managing on-page interactions.
Access this namespace via allegro.interaction.
Methods
remove()
remove(
slug):void
Defined in: interaction/types.ts:68
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:49
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? | { data?: Record<string, unknown>; skipDelays?: boolean; slug?: string; } | - |
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:33
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:80
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');