Script Tag
Add the following tag to your page to load the Allegro SDK:
<script src="https://your-allegro-instance.com/client.js"></script>
Replace your-allegro-instance.com with your Allegro domain.
How It Works
client.js is a tiny loader script served by Allegro. When it runs, it creates
a new <script> element pointing at the compiled SDK, injects two attributes
automatically (data-csrf-token and data-tenant-config), and appends it to
<head>. Any attributes you add to the original tag are forwarded to the
injected script.
On load the SDK:
- Reads configuration from the script tag attributes.
- Creates or restores device and session identifiers.
- Registers the built-in web components.
- Fires a
page_viewevent. - Dispatches
allegro:readyonwindow.
Attributes
| Attribute | Injected automatically | Description |
|---|---|---|
data-tenant-config | Yes | JSON object with tenant settings (enabled login providers, cookie domain, etc.). |
data-debug | No | Enable debug mode. Presence of the attribute (or ="true") is enough. See Debug Mode. |
data-api-url | No | Override the API base URL. Defaults to the origin of client.js. Rarely needed. |
Debug Mode
Debug mode writes verbose SDK logs to the browser console. Enable it in any of three ways:
Attribute on the script tag:
<script src="https://your-allegro-instance.com/client.js" data-debug></script>
URL parameter (persisted to localStorage for the session):
https://example.com/article?allegro_debug=1
Pass allegro_debug=0 to clear it.
Browser console (takes effect immediately, persists across page loads):
window.allegro.debug();
allegro:ready Event
The SDK dispatches allegro:ready on window once initialization is complete.
Use this if you need to interact with the SDK after it has loaded but cannot
guarantee the callback queue has been set up:
window.addEventListener('allegro:ready', function () {
window.allegro.push(function (allegro) {
// SDK is ready
});
});
For most use cases the event queue pattern is simpler —
callbacks pushed to window.allegro before the SDK loads are replayed
automatically.
Async Loading
The loader script is injected with async = true by default so it does not
block page rendering. To load the SDK synchronously (for example, in a
server-side rendering environment where you need it available before paint), add
?async=false to the client.js URL:
<script src="https://your-allegro-instance.com/client.js?async=false"></script>