Skip to main content
All CollectionsDeveloper Support Docs
Javascript SDK API Reference

Javascript SDK API Reference

Charley Bader avatar
Written by Charley Bader
Updated over a week ago

intent.bus.subscribe()

Executes a callback function when Intent makes a prediction based on the event type you subscribe to. Registering events on the event bus allows you to receive events and dispatch them to one or more destinations in real time. Note that using Browser Events may be preferable when you need to ensure that events are registered berfore the Intent Client Script has loaded.
​

intent.bus.subscribe(
<event-type>,
<function(inferenceData, sessionMatchedSegments, eventMatchingSegments)>
)

Parameters

Parameters

Description

<event-type>

The type of event that was dispatched based on user activity on site.

Expected Values:

interaction - (dispatched on every page view, add to cart, conversion, click)

event - as interaction, but including beacon events dispatched during periods of site inactivity

click - dispatched on every click

page_view - dispatched on every page view

add_to_cart - dispatched on every add to cart

conversion - dispatched on every conversion

<function.inferenceData>

The response data returned from Intent's modelling service

<function.sessionMatchedSegments>

An array of all segments that have matched in the user's current session.

<function.eventMatchingSegments>

An array of all segments that matched for this event, i.e. right now.

Example

intent.bus.subscribe('event', ({
inferenceData,
sessionMatchedSegments,
eventMatchingSegments
}) => {
console.log(
inferenceData,
sessionMatchedSegments,
eventMatchingSegments
);
});

intent.dataLayer.push()

Track events to our service endpoints for ingestion.

For more information see The Intent Tag SDK

intent.lastInference

A reference to the last inference data response. Modelled and analytical data points are exposed in intent.lastInference.data.

intent.segments.currentMatches

A list of segments that were matched on the last tracked event.

intent.segments.persisted

A list of all segments that matched for during the current session - on the last tracked event or on any event before it. This is useful for when you want to persist campaigns you run off the back of these segment matches.

intent.version

The version number of the Intent Client Script deployed on site.

Did this answer your question?