Custom Events

Track custom user interactions and events.

Using the Track API

Track custom events using the palace.track() function. In React and other module-based frameworks, use palace.track():

// Track a simple event
palace.track('signup');

// Track an event with data
palace.track('purchase', {
  product: 'Premium Plan',
  price: 99.99,
  currency: 'USD'
});

// In React/modules, use palace directly
palace.track('signup');

Event Data

You can pass any JSON-serializable data as the second parameter. This data will be sent along with the standard tracking information.

palace.track('video_play', {
  video_id: 'abc123',
  video_title: 'Getting Started',
  duration: 180,
  autoplay: false
});

Auto-Initialization

By default, the tracker initializes automatically when the page loads. If you set data-auto-track="false", you can manually trigger initialization by calling palace.track() for the first time.

// With data-auto-track="false"
// First call initializes the tracker
palace.track('pageview');