JavaScript API

Overview

The tracking code included on your page adds a seaurchinIO(<action>, <data>) function to the window scope. This function serves as the interface between your page and the SeaUrchin.IO data capture logic.

init

seaurchinIO('init', <your app id>);

Initialize the tracking code. This will result in an async request for the app's config data. Only the first "init" call made on a page will take effect.

Identify

Use the identify call to optionally tag a session with the user's unique identifier and any set of custom properties. This call can be invoked multiple times per session. In case of conflicts, the last value set for each property is used.

These properties will be added to matching search interactions in the data export.

identify

seaurchinIO('identify', <key value map>);

Example

seaurchinIO('identify', {
    "user_id": "12345",
    "custom_property": "custom value"
});

Custom Logging

This section is for advanced scenarios that fall outside of the auto capture capabilities. Most implementations will not need to leverage these API calls. For code-less configurations, see the auto capture instructions.

optout

seaurchinIO('optout', true | false);

Opt out of SeaUrchin.IO tracking. The browser making this call will be excluded from all SeaUrchin.IO tracking on the domain the call was made from.


log

seaurchinIO('log', <event data>);

Manually log an event. See the "Data Format" section below for more details.

Data Format

The document below details the JSON structure SeaUrchin.IO uses to represent search event data. When using the manual logging feature, the data passed to seaurchinIO('log', <data>) should conform to this format.


Search event

keyvaluedescription
fflow idnumber
e"s"event type
susearch urlstring
sqsearch querystring
sosearch offset / pagenumber -- later pages should have higher numbers
sfsearch facetsJSON object containing facet: [values] mappings
sdsearch durationnumber in milliseconds

Result display event

keyvaluedescription
fflow idnumber
e"d"event type
diresult container idgenerated uuid string
dtresult container top offsetnumber -- used to calculate result ordering (items higher up should have smaller values than those below)
dlresult container left offsetnumber -- used to calculate result ordering (items on the left should have smaller values than those on the right)
dcresult titlestring
duresult urlstring
dpresult pricestring (null if not applicable)

Result click event

keyvaluedescription
fflow idnumber
e"c"event type
ciresult container idgenerated uuid string -- should match id of the corresponding display event
ccresult titlestring
curesult urlstring

Item page view event

keyvaluedescription
fflow idnumber
e"i"event type
iuitem page urlstring
itdwell time on page in millisecondsnumber

Goal -- set items event

keyvaluedescription
fflow idnumber
e"f"event type
figoal idnumber
faarray of associated item objectsitem object -- { name: <name (string)>, url: <url (string)>, quantity: <quantity (string)>, price: <unit price (string)> }
fsorder subtotalstring

Goal -- conversion event

keyvaluedescription
fflow idnumber
e"g"event type
gigoal idnumber -- should match id of the corresponding goal set items event
Can't find what you're looking for? Send an email to support@seaurchin.io