Skip to main content

Event Tracking

Use allegro.track() to record events. The SDK handles session creation, device identification, and page metadata collection automatically.

Basic Usage

window.allegro.push(function (allegro) {
allegro.track('page_view');
});

allegro.track(eventName, data?)

Track an event. Returns a promise that resolves with { event_id: string }.

The SDK automatically:

  • Creates a session if one doesn't exist
  • Includes device ID, session ID, and CSRF token
  • Collects page metadata from the DOM (title, content type, publisher, etc.)
  • Attaches the logged-in customer ID if available

With event data

allegro.track('article_read', {
content_id: 'article-456',
content_type: 'premium',
publisher: 'Daily News',
});

With custom data

allegro.track('purchase', {
data: {
product_id: 'sku-789',
price: 9.99,
currency: 'USD',
},
});

Available fields

FieldTypeDescription
urlstringPage URL (auto-collected by default)
refererstringReferring URL
page_titlestringPage title
content_typestringContent type (e.g. article, video)
content_idstringContent identifier
publisherstringPublisher name
object_typestringObject type
object_idstringObject identifier
contextstringContext or category
conversion_pv_idstringConversion page view ID
url_in_clickstringClicked URL
dataRecord<string, unknown>Arbitrary custom data

For more information, see Page Metadata.

Session & Device Management

The SDK manages two cookies:

CookieLifetimePurpose
allegro_device_id10 yearsPersistent device identifier (UUID v4)
allegro_session_id30 minutesSession identifier, extended on activity

Sessions are created automatically on the first track() or member.login() call. Each track() call extends the session timeout.