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:45
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');
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:57
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');