Developer Platform Overview
The Allegro SDK is a lightweight JavaScript library for event tracking, session
management, and member authentication. It loads asynchronously and exposes its
API on window.allegro.
Installation
Add the loader script to your page:
<script src="https://your-allegro-instance.com/client.js"></script>
For more information, see the script tag documentation.
Core Concepts
Async Queue
The SDK uses an async queue pattern so you can start using it before it finishes loading:
<script>
window.allegro = window.allegro || [];
// Queue a callback
window.allegro.push(function (allegro) {
allegro.track('page_view');
});
</script>
<script src="https://your-allegro-instance.com/client.js"></script>
When the SDK loads, it replaces the array with the full SDK, drains the queue, and executes each callback.
allegro.push(callback)
Queue a function to run when the SDK is ready. If the SDK has already loaded, the callback executes immediately.
window.allegro.push(function (allegro) {
// SDK is ready — use allegro.track(), allegro.member, etc.
});
What's Available
| Namespace | Description |
|---|---|
allegro.track() | Track events with automatic session and device management |
allegro.member | Authenticate members, get user info and entitlements |
allegro.interaction | Trigger interaction events |
See the Quick Start guide for a complete working example, or browse the API Reference for full type documentation.
Session & Device Management
The SDK manages two cookies automatically:
| Cookie | Lifetime | Purpose |
|---|---|---|
allegro_device_id | 10 years | Persistent device identifier (UUID v4) |
allegro_session_id | 30 minutes | Session identifier, extended on activity |
Sessions are created automatically on the first track() or member.login()
call.
Error Handling
API errors throw an AllegroApiError with the HTTP status and response body:
try {
await allegro.member.login('bad@email.com', 'wrong');
} catch (error) {
console.error(error.status); // e.g. 401
console.error(error.body); // server response
}
Errors inside push() callbacks are caught and logged to the console — they
won't break the queue or prevent other callbacks from running.