Skip to content
Talk to an engineer

Get started

User context

User context is how you track the users and subscriptions using your agent, with built-in and custom attributes. Calling foldspace.identify() ties each session to a real user (and their account or subscription) so conversations, Product analytics, and Segments carry real identity and attributes instead of anonymous sessions.

It’s optional — the agent runs without it — but in production it’s what makes users and subscriptions trackable. Pair it with Custom events to also track what those users do (usage).

Create custom user and subscription attributes under Settings → Attribute Settings, then send their values with identify() using each attribute’s API Name.

Pass a context object to foldspace.identify() once the SDK is ready.

const context = {
user: {
id: '7d8da9a5-53f3-4bc0-8921-1cceecb8107',
},
subscription: {
id: 'subscription-12345'
// add custom attributes here after creating them in Attribute Settings
}
}
foldspace('when', 'ready', () => {
foldspace.identify(context);
});

Add any of the optional attributes below to enrich the user record.

const context = {
user: {
id: '7d8da9a5-53f3-4bc0-8921-1cceecb8107',
email: 'user12345@example.com',
name: 'John Doe',
role: 'admin',
image: 'https://example.com/images/user12345.jpg',
phone: '+1234567890',
timezone: 'America/New_York',
signUpDate: 1707164462000,
location: {
country: "USA",
region: "Northeast",
state: "New York",
city: "New York City",
postalCode: "10001"
}
// add custom attributes here after creating them in Attribute Settings
},
subscription: {
id: 'subscription-12345'
// add custom attributes here after creating them in Attribute Settings
}
}
foldspace('when', 'ready', () => {
foldspace.identify(context);
});