Skip to main content

Custom JS Triggers

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

Custom JS triggers allow you to write your own code to handle segment matching.

In a nutshell, our services are continually modelling user behaviours throughout their journey as inferences, and data is surfaced frequently to inform a user's current phase in relation to their Intent. This drives segmentation and you can piggy back onto inferences in realtime.

Event capturing using triggers

  1. Create the trigger

  2. Copy and paste the execution code shown to you in the trigger modal. It looks like this:

    document.addEventListener(
    'intent.campaign.<trigger ID>',
    function(e) {
    // Run campaign code here
    }
    );

  3. Save the trigger

  4. When the segment matches subject to the method and trigger conditions given to it, the 'intent.campaign.<trigger ID>' event is dispatched and the callback function invoked

This event is dispatched every time that this experience is triggered. Note: you should register this event listener before the Intent client script is loaded and page view events are dispatched.

Did this answer your question?