Skip to main content

Event Tracking Methods

Methods for tracking events, identifying users, and managing user sessions.

track

Track a custom event with optional properties.
event
string
required
Event name. Use descriptive names like Button Clicked or Purchase Completed.
properties
EventProperties
Optional event properties. Can include any JSON-serializable data.

Returns

void

Example

// Simple event
solute.track('Button Clicked');

// Event with properties
solute.track('Purchase Completed', {
  product_id: 'prod_123',
  price: 99.99,
  currency: 'USD',
});

identify

Identify a user and associate events with them.
userId
string
required
User ID. Should be a unique identifier for the user.
traits
UserTraits
Optional user traits. Properties that describe the user.

Returns

void

Example

// Identify with traits
solute.identify('user_123', {
  email: '[email protected]',
  name: 'John Doe',
  plan: 'premium',
});

// Identify without traits
solute.identify('user_123');

page

Track a page view.
name
string
Optional page name. If not provided, will use the current page path.
properties
EventProperties
Optional page properties.
category
string
Optional page category.

Returns

void

Example

// Simple page view
solute.page('/pricing');

// Page view with properties
solute.page('/pricing', {
  category: 'Marketing',
  title: 'Pricing Page',
});

// Page view with name and category
solute.page('Pricing Page', {
  plan: 'premium',
}, 'Marketing');

group

Associate a user with a group or organization.
groupId
string
required
Group ID. Should be a unique identifier for the group.
traits
GroupTraits
Optional group traits. Properties that describe the group.

Returns

void

Example

solute.group('company_123', {
  name: 'Acme Corp',
  plan: 'enterprise',
  employees: 50,
});

alias

Merge anonymous and identified user identities.
newId
string
required
New user ID (the identified user ID).
previousId
string
Previous user ID (usually the anonymous ID). If not provided, will use the current anonymous ID.

Returns

void

Example

// Alias anonymous ID with user ID
const anonymousId = solute.getAnonymousId();
solute.identify('user_123');
solute.alias('user_123', anonymousId);

reset

Reset user identity and start a new session. Useful when a user logs out.

Returns

void

Example

// On logout
solute.reset();

flush

Force immediate sending of all queued events.

Returns

Promise<void>

Example

// Flush events before page unload
window.addEventListener('beforeunload', () => {
  solute.flush();
});
Events are automatically flushed based on your queue configuration. You typically don’t need to call flush() manually.