This is a Jitsu.Classic documentation. For the lastest version, please visit docs.jitsu.com. Read about differences here.

πŸ“œ Configuration

Configuration UI

πŸ‘©β€πŸ”¬ Extending Jitsu

Overview
Destination Extensions
Source Extensions
API Specs

Jitsu Internals

Jitsu Server

NPM package

Jitsu JS SDK available as an npm package. Npm/yarn is a preferred way of sending data to Jitsu for applications build with modern frameworks such as React, Angular, Vue etc.

Of you're using no-code tools such as Webflow, Wix, Wordpress etc - html snippet will work better

Check out Jitsu React Guide. Special guides for other frameworks are coming soon!
For server-side tracking, read Node.js guide

Installing Jitsu

Use the following command to add it to your project:

npm
yarn
npm install --save @jitsu/sdk-js

To initialize Jitsu, please use:

const { jitsuClient } = require('@jitsu/sdk-js');
const jitsu = jitsuClient({
    key: "[API_KEY]",
    ...params
});

Please see the full list of parameters, a key parameter value is required.

Sending data

Jitsu exposes only two methods id() - for identifyling users and track() for sending events.

ID method

id() sets the properties of the user (such as name, e-mail, internal id β€” any parameters are accepted)

jitsu.id({
    "name": "Man with No Name",
    "email": "thegoods@western.com",
    "id": "6"
})

By default, a user_identification event will be sent. However, it can be changed by setting the second parameter to true.

jitsu.id({...}, true);

Track method

jitsu.track() is used to record any event that happens on a webpage

Syntax
Example
jitsu.track('{event_name}', {...event data})

If id() has been called prior to track(), all user details will be included. Also, do not include parameters such as page URL and user agent. Jitsu collects this automatically! Read more about our event scheme.

Persistent properties

Persistent properties are properties that are set once and sent with every track event:

jitsu.set({ project : 'X' })

will make jitsu to send {project: 'X'} with each jitsu.track() call. Use:

  • jitsu.set({ project : 'X' }, { eventType: 'pageview' }) to associate properties only with specific event type
  • jitsu.set({ project : 'X' }, { persist: false }) to not persist properties in cookies across sessions

Intercepting Segment events

As Jitsu, can serve as Segment replacement, you can optionally intercept events that has been sent to segment before

Preferred way of doing that would be supplying jitsu with Analytics object explicitely

const jitsu = jitsuClient({
    key: "[API_KEY]",
    ...params
});

//Create analytics via npm module
const analytics = new Analytics();
//initialize interception explicitly
jitsu.interceptAnalytics(analytics);

However, if analytics.js is injected as code snippet, not as a package following code will do the job:

const jitsu = jitsuClient({
    key: "[API_KEY]",
    segment_hook: true // instruct jitsu to automatically intercept events
});

Please make sure that this code executed before initialization of Segment's analytics.js