JavaScript SDK

The Cueflow JavaScript SDK displays messages (banners, modals, checklists, feedback surveys, and changelogs) to your users directly in your application.

Installation

Add the loader script to your application's <head> tag:

<script>
(function(w,d,i){
  w.Cueflow=w.Cueflow||{q:[],
    init:function(u){this.q.push(['init',u])},
    update:function(u){this.q.push(['update',u])},
    track:function(e,p){this.q.push(['track',e,p])},
    check:function(){this.q.push(['check'])},
    shutdown:function(){this.q.push(['shutdown'])}
  };
  var s=d.createElement('script');s.async=1;
  s.src='https://script.cueflow.so/embed/cueflow.js';
  s.setAttribute('data-workspace-id',i);
  d.head.appendChild(s);
})(window,document,'YOUR_WORKSPACE_ID');
</script>
circle-info

Find your Workspace ID on the Developer Guidearrow-up-right page in the Cueflow dashboard.

Initialize with User Data

After the script loads, initialize Cueflow with your user's information:

User Data Reference

Required Fields

Field
Type
Description

id

string

Unique identifier for the user

Standard Fields

Field
Type
Description

email

string

User's email address

name

string

User's display name

phone

string

User's phone number

avatarUrl

string

URL to user's avatar

role

string

User's role in your app

plan

string

Subscription plan

signedUpAt

ISO string

When the user signed up

Custom Attributes

circle-info

Custom attributes must be defined in your Attributesarrow-up-right page first. They are available for targeting rules and personalization.

How It Works

  1. Script loads - Cueflow SDK initializes on your page

  2. User identified - You call Cueflow.init() with user data

  3. Messages fetched - Cueflow checks which messages match this user

  4. Messages displayed - Matching banners, modals, etc. are rendered

  5. Navigation tracked - On SPA navigation, messages are re-evaluated

Available Methods

Method
Description

Initialize with user data

Update user attributes

Track custom events

Manually check for messages

Remove all messages and cleanup

SPA Support

Cueflow automatically detects navigation in Single Page Applications by listening to:

  • pushState / replaceState calls

  • popstate events

When navigation is detected, Cueflow re-evaluates targeting rules and shows/hides messages accordingly.

circle-info

If your SPA uses a custom routing mechanism, call Cueflow.check() after navigation to manually trigger message evaluation.

Next Steps

Last updated