Cueflow.init()

Initialize Cueflow with user data. This must be called before any other methods.

Syntax

Cueflow.init(user)

Parameters

user (required)

An object containing user information:

Property
Type
Required
Description

id

string

Yes

Unique identifier for this user (your internal user ID)

email

string

No

User's email address

name

string

No

Display name

phone

string

No

Phone number

avatarUrl

string

No

URL to profile image

role

string

No

User's role (e.g., "admin", "member")

plan

string

No

Subscription plan (e.g., "free", "pro", "enterprise")

signedUpAt

string

No

ISO 8601 date when user signed up

[custom]

any

No

Any additional custom attributes

Basic Example

Full Example

When to Call

Call init() after your user is authenticated and you have their information:

Important Notes

Call Only Once

init() should only be called once per page load. Calling it again will show a warning:

If you need to update user data after initialization, use Cueflow.update().

ID is Required

The id property is mandatory. Without it, initialization will fail:

Use Consistent IDs

Always use the same id for the same user across sessions. This ensures:

  • Targeting rules work correctly

  • Dismissals are remembered

  • Event history is tracked properly

Custom Attributes

Any properties beyond the standard ones become custom attributes:

Custom attributes can be used for targeting in the Cueflow dashboard:

  • company equals "Acme Inc"

  • accountAge greater than 30

  • hasCompletedOnboarding equals true

Attribute Types

Type
Example
Targeting Operators

String

company: "Acme"

equals, not equals, contains

Number

teamSize: 50

equals, greater than, less than

Boolean

isPremium: true

equals, not equals

TypeScript

If using TypeScript, you can type your user object:

Error Handling

The script handles errors gracefully and logs warnings to the console:

Warning
Cause

"Cueflow: Already initialized"

init() called more than once

"Cueflow: user.id is required"

Missing id property

"Cueflow: workspace-id not found"

Missing data-workspace-id on script tag

Next Steps

Last updated