Skip to main content

Browser Javascript SDK

The Browser Javascript SDK can only run in the browser.

Installation Example

const sg = Segmentik.load({
apiKey: 'API-KEY-EXAMPLE'
});

sg.then(function(session) { return session.detect() })
.then(function(data) { console.log(data) });

For full installation instructions, please read Quick-Start Guide.

SDK Methods

The SDK supports two methods:

  • load() - will download the SDK into the browser context. Calling this method will not bill your account.
  • detect() - runs the detection, collecting device information and sends it to Segmentik's servers for inspection. Calling this method will be billed.

load() Options

  • apiKey: string (required)
    You can get your API key from the dashboard. On the side-bar, click on "Integration" and you will find your API key. It should be an alphanumeric string of 20 character long. Example: RJCK7J8SDCG4ZADJTGS2

detect() Options

tags: object (optional)

Used for tagging this detection for later use. Tags will be included in the response of the detection and can be used for querying Segmentik's API. Tag value can be string, boolean or null. Example:

session.detect({
tags: {
userId: '6711',
campaign: 'facebook'
}
})

identifier: string (optional)

For advanced use only - use only if you know what you are doing.

In some cases, when you don't need a real-time detection, you can label a session with a unique identifier. This identifier can later be used to query for the detection result.
Important: Make sure that the identifier you pass is unique, otherwise you might get the wrong detection result by the API.