Events

Track pageviews and custom events to understand user behavior across your application.

Pageview Tracking

Pageviews are the fundamental tracking unit. They capture when a user views a page or screen.

Automatic Pageviews

With autoPushPageview: true (default), a pageview is tracked automatically on initialization.

Manual Pageviews

For single-page applications or custom navigation:

// Track a pageview manually
alkeAnalytics.pushPageView();

The SDK automatically captures:

  • Current URL (normalized, without tracking parameters)
  • Page title
  • Referrer
  • Session data

Custom Events

Track specific user interactions beyond pageviews.

pushEvent()

// Simple event
alkeAnalytics.pushEvent('button_click', 'share_button');

// Event with custom data included
alkeAnalytics.pushEvent('purchase', 99.99, true);
ParameterTypeDescription
eventNamestringrequiredName of the event (e.g., 'button_click', 'video_play')
eventValuestring|number|booleanoptionalOptional value associated with the event
includeCustomDatabooleanoptionalInclude current custom data with this event. Default: `false`

Flushing Events

Events are automatically sent when:

  • The page/app goes to background
  • The page is about to unload (web)
  • A new pageview is tracked

You can also manually flush:

Events are flushed automatically on visibilitychange and pagehide. Manual flush is rarely needed.

Engagement Tracking

Track how much of the content users actually consume.

Scroll engagement is tracked automatically. The SDK records the maximum scroll depth as a percentage (0-100).

// Override with custom engagement (e.g., video progress)
alkeAnalytics.setEngagementPercent(75);