← Documentation

Tracker functions

You can call these functions from your site when you want to control what gets tracked. Out of the box, pageviews and events are captured automatically. To turn that off and send data yourself, set data-auto-track="false" on the script. Details are in Tracker configuration.

Available functions

// Tracks the current page
intrily.track();

// Custom payload
intrily.track(payload: object);

// Custom event
intrily.track(event_name: string);

// Custom event with data
intrily.track(event_name: string, data: object);

// Assign ID to current session
intrily.identify(unique_id: string);

// Session data
intrily.identify(unique_id: string, data: object);

// Session data without ID
intrily.identify(data: object);

Pageviews

Send a pageview for the current page:

intrily.track();

The tracker normally sends: hostname, language, referrer, screen, title, url, and website (required). To override with your own data, pass an object:

intrily.track({ website: 'your-website-id', url: '/home', title: 'Home page' });

To keep the defaults and only change a few fields, pass a function that receives the existing props:

intrily.track(props => ({ ...props, url: '/home', title: 'Home page' }));

Events

Send a named event:

intrily.track('signup-button');

Event data

Attach extra data to an event:

intrily.track('signup-button', { name: 'newsletter', id: 123 });

Default properties (url, referrer, etc.) are still sent. The call above is the same as:

intrily.track(props => ({ ...props, name: 'signup-button', data: { name: 'newsletter', id: 123 } }));

Event data limits

Event payloads support JSON, with these limits to keep things fast:

  • Numbers: up to 4 decimal places.
  • Strings: up to 500 characters.
  • Arrays: turned into a string; that string is also capped at 500 chars.
  • Objects: up to 50 keys. An array counts as one key.

Sessions

Attach an ID to the current session so you can recognize the same user later:

intrily.identify('unique_id');

Session data

Store extra info for the current session (e.g. plan type, role):

intrily.identify('unique_id', { name: 'Bob', email: 'bob@example.com' });

You can also send only an object and skip the ID:

intrily.identify({ name: 'Bob', email: 'bob@example.com' });