# Architecture overview
Source: https://developers.candu.ai/docs/architecture-overview
An overview of what Candu is and how it has been designed
## Design principles
Candu has been designed with the following principles in mind:
* **Adapt to your application:** We recognize that every business has different needs when it comes to content and UI. We created Candu in a way that enables your content to easily adapt and integrate with your app.
* **Always available:** We know that your solution has high availability needs, which is why Candu scales to your demands.
* **Customization as a first-class citizen:** In the enterprise world, every customer has a need for a unique solution. We wanted to make sure to create a tool that can be easily personalized and adapted depending on each customer need.
* **Analytics to drive better outcomes:** At Candu, we believe that, in order to drive better outcomes, work on both qualitative and quantitative levels is needed. Our personalization features give you the ability to work closely with your customers, while our native analytics enable you to take a more quantitative approach.
## Architecture at a Glance
The below diagram details information flowing from the user, through the Candu SDK, API, CDN, and Content, the returning to the provider and user.

## Candu's components
Let's look at all the various entities in Candu and talk about their role:
### Dashboard
In the dashboard, you can edit Content, manage Segments, and view Analytics. Here, you'll also find API keys and client token, and be able to manage your application's security settings. To visit your dashboard, [log in here](https://app.candu.ai/login)
### SDK
The Candu SDK is installed inside your application to help you render content for your customers and provide them with additional functionality.
The SDK's main functionalities are:
1. Rendering [Content](https://docs.candu.ai/en/articles/5899385-content-overview)
2. Collecting [Analytics](https://docs.candu.ai/en/articles/5917168-analytics-overview) via [Eventing](https://docs.candu.ai/en/articles/5918152-tracking-custom-events)
### CDN
In order to provide high availability and fast delivery, Candu uses a CDN to publish Content. While you're editing Content from our dashboard, they will be saved on our servers.
However, once you publish them, we will upload them to our CDN. We use this publishing mechanism to:
1. Provide a safety mechanism so that your customers won't see every draft that you save.
2. Increase the speed and availability of any content that you create.
3. Provide a versioning mechanism for any content that you create.
### Styleguide
The Styleguide is a fundamental part of the application. We created this abstraction for the following reasons:
1. **Customize presentation and styling:** Integrating a style guide with the SDK enables you to customize every item style so that each UI element matches your intended product experience.
2. **Add functionality:** The Styleguide API enables you to implement advanced use-cases by customizing the order in which each tree is rendered and allowing you to customize how each component is constructed.
Learn more about how Styleguide works in our [in-depth guide.](https://docs.candu.ai/en/articles/5900089-self-serve-styleguide)
### Eventing
Candu has a number of eventing integrations to make it easy to get data in and out. Customers can send us data directly via [Javascript Eventing](/docs/getting-started) or integrate using [Setting up Outgoing Webhooks](/docs/setting-up-outgoing-webhooks). We also offer a number of integrations that you can use to set up eventing. Check the [integrations page](https://docs.candu.ai/en/collections/3296166-integrations) to see all avaliable options.
# CDN & Caching
Source: https://developers.candu.ai/docs/caching
At Candu, we go to great length to ensure that any component that we load will be served to your customers extremely quickly. Since the very beginning, we've have always implemented a [High Avaliability Architecture](/docs/architecture-overview), with a strong focus on [Performance & Reliability](/docs/reliability-availability).
In this article, we'll be discussing some of our caching choices and how they will impact your customer experience.
## Strategy overview
To provide the best customer experience, we adopt a tiered strategy across several network layers:
* **Browser caching:** Browser caching refers to the process of storing web resources on the client's web browser. When a user visits a website, the browser downloads these resources and stores them locally. The next time the user accesses the same website, the browser checks if it already has a cached copy of the requested resource before fetching it from the server. If a cached copy exists and is still valid the browser retrieves the resource from its local cache.
* **Edge caching**: Edge caching, also known as content delivery network (CDN) caching, takes place at the edge servers distributed in various geographical locations. CDNs consist of a network of servers located closer to end users. Candu uses Cloudflare as CDN. When a user requests a resource, the CDN's edge server closest to the user's location handles the request. If the requested resource is already cached on the edge server, it is delivered directly to the user without having to traverse the entire network path to the origin server.
## Content
Content is served as `json` from `https://cdn.candu.ai/contentDocument`. We adopt the following strategy:
* **Browser cache**: 5 minutes.
* **Edge cache**: at least 4 hours. Cache is invalidated when a content is published.
If you publish a new content version, changes will be seen by all your users within 5 minutes, depending on when the asset was stored in their browser cache.
Changes to the segment membership will automatically invalidate the cache.
## Placements and Configuration
Placements and configuration are served as `json` from `https://cdn.canud.ai/config`. We adopt the following strategy:
* **Browser cache**: 5 minutes.
* **Edge cache**: at least 4 hours. Cache is invalidated when there are changes to placements.
If you update any placement, changes will be seen by all your users within 5 minutes, depending on when the asset was stored in their browser cache.
## Segment membership
On every page load (`Candu.init`), the SDK fetches fresh segment membership from the network. To render instantly, it also uses the membership it stored in the browser on the previous visit (kept per user ID for up to 24 hours) and updates the content if the fresh result differs.
* Within an open page, membership does not change until the next page load. To re-evaluate immediately after traits change or an event fires, call [`Candu.refreshMembership()`](/docs/getting-started#candu-refreshmembership).
* The stored membership is keyed by user ID, so a different user logging in on the same browser gets their own membership.
* If you narrow a live segment, users with a page already open keep the earlier membership until they reload.
## CSS assets
Given that css assets play a big role in the end user experience we employ the following strategies:
* **Browser cache**: 5 minutes. Some assets that already have versioning build in will have longer caching since they will expire immediately when a new version is published.
* **Edge cache**: at least 4 hours. Cache is invalidated when are changes to placements.
## SDK
Since the SDK is not updated often, we have a much longer caching strategy.
* **Browser cache**: 4 hours.
* **Edge cache**: at least 4 hours. Cache invalidation is managed exclusively by Candu engineers when releasing new versions.
# Managing Candu divs
Source: https://developers.candu.ai/docs/creating-candu-specific-divs
When Embedding Candu components, several customers of ours prefer to have their developers manually add divs for specific Candu content. We recommend this practice when:
1. A team uses Candu for a business critical use case such as a homepage or getting started page. In which case, it is preferable to have a div in code so that the teams can:
1. Make sure the content will persist across deploys, and not be removed accidentally by the dev team.
2. Add integration testing such as Cypress to verify that Candu is rendering consistently and correctly.
2. Class names are autogenerated, so inherently non-stable. This is common when using libraries such as [Styled Components](https://styled-components.com/).
3. There is no viable `div ` to inject the content where you would like to.
4. You would like to conditionally show or hide content based on application status. A common use case as such are empty states.
1. If a customer has no records then `
` else render the records.
To learn more about embedding content into your existing UI with Candu view our guide [here. ](https://docs.candu.ai/en/articles/5916841-launching-candu-content)
***
## Adding a div
### Step 1: Identify the Placement and Purpose
Determine where and why you want to add new divs to your product pages. Consider the specific functionality or content you wish to include within these divs. Additionally, determine which div will be used to embed Candu content.
### Step 2: Identify the Appropriate Section
Within the HTML file, locate the section or container where you want to add the new divs. This could be a specific `` element, a section identified by an ID or class, or any other suitable HTML element that serves as a container.
### Step 3: Add the New Divs
Within the identified section, add new `
` elements to create the desired divs. For the div where you want to embed Candu content, ensure you assign a unique ID or class to it. We recommend adding a comment to document why a given div has been added.
```html theme={null}
```
### Step 4: Deploy the code
Ship the new div to production to be able to target it from the Chrome extension or as a Candu Placement.
***
# # Best practices
### Clear Naming Convention:
We recommend using clear naming like candu-homepage, candu-emptystate or candu-banner so your team can easily identify the spot that has been allocated for them to use.
### Size and Responsiveness:
Ensure that the div where you embed Candu content has appropriate dimensions to display the content properly, for example a full page takeover vs. sidebar only. Consider the size of the Candu content and make sure the div can accommodate it without distortion or overflow. Additionally, make the div responsive so that the Candu content adjusts well on different screen sizes.
### Unique ID
When embedding Candu content into a `div`, ensure that the div retains a consistent and unique ID. This prevents the content from being regenerated with a unique ID on every page load. Keeping a consistent ID ensures a seamless experience and avoids unnecessary content reloading.
### Repeating Content
If a `div` repeats across multiple pages, communicate this clearly to your team. They should be aware that the content will repeat unless they set up URL targeting in Candu where they can specify which page(s) they want to display the content on.
By following these steps and considering the Candu content-related factors, you can effectively add new divs to your product pages and seamlessly integrate Candu content into the designated `div`.
# DOM API
Source: https://developers.candu.ai/docs/dom-api
Candu's DOM API defines a DOM interface to be able to easily query Candu's state via DOM.
This API often used for the following use cases:
* Testing Candu components via Cypress, Selenium or other integration tests.
* Verifying if a component has rendered.
* Calculate to Fist Paint for a given Candu component.
* Query what components are active on a given Candu page
Here is an example of a Candu injected div.
```html Html theme={null}
#shadow-root
```
### id
The Id is a UUID that's randomly generated for internal state keeping purposes. The ID is not stable, and we do not recommend using this id.
### candu-content-id
A `content-id` is an identifier used to reference Content. They are unique across all of Candu. You can find a content id in the editor URL: `/editor/
/*`. A content can be injected twice in a given page, so the data attribute may not be unique.
### candu-slug
The `slug` is a human readable identifier used for a given Content. A content can be injected twice in a given page, so the data attribute may not be unique.
### candu-placement-id
The `placement-id` is an identifier used to reference which placement is being used for a given piece of content. Placements are set in the `Content`/`Placements` tab. If a content is rendered programmatically using `renderContent` the `placementId` will be a non-stable randomly generated id.
### candu-selector
The selector that is being targeted by a given placement.
### candu-selector-location
Where a Content is being placed in side the selector. Possible values are `End`, `Start` and `Replace`.
# Core entities
Source: https://developers.candu.ai/docs/entities
Understand Candu content, placements, segments, and documents.

## Content
Identifier: `contentId`
A content is Candu's core entity. Contents can have many different types, such as `Inline`, `Modal`, `Tour` or `HotspotGroup`. Each Content can be Live or Published.
Content can also be used inside other pieces of Content as an `Embed`, so that you can create complex nested logic.
## Placement
Identifier: `placementId`
Placements are responsible for showing the right Content in the right place. Each Content can have multiple placements, which in turn can have multiple URL rules and selectors. Selectors can be reused across multiple pieces of Content.
## Segment
Identifier: `segmentId`
Segments are a set of users. Segments are used to target users and to create dynamic content.
The "Everyone" Segment contains all your users and has `segmentId=Everyone`.
A Content can be targeted to any number of Segments, each one will have their own document. A user will be shown the first Segment they match.
## Document
Identifier: `documentId`
A Document is responsible for maintaining version history, commit log and publishing state for a given set of nodes.
The exact `versionId` can be accessed in all the tracking calls, in case you want to track version changes. `VersionIds` are `sha1` hashes.
## Components and Node
Identifier: `nodeId`
Components are logical grouping of nodes. For example, a `Checklist` component contains two types of nodes, `ChecklistGroup` and `ChecklistItem`.
Nodes are organised in a tree data structure, and are created to reflect how the DOM works.
> [!WARNING]
>
> A `nodeId` is not unique across Candu, but the combination of `documentId` and `nodeId` is.
# Candu SDK Event Names
Source: https://developers.candu.ai/docs/eventing-schema
Candu's SDK emits events to both Candu servers and your customer application. These events help track user interactions and analyze product usage.
To familiarize yourself with all the identifiers, read more about Candu's [Entities](/docs/entities).
All Candu SDK events start with the prefix `candu.sdk`.
# Common Events
Content events are generic events common to every type of content.
Every SDK event includes a core set of identifiers. Depending on the event type, additional properties may be included.
| Identifier | Type | Description |
| :- | :- | :- |
| `contentId` | `String` | Identifies the Content that triggered the event |
| `segmentId` | `String` | The Segment that was matched against the user when the event fired. |
| `documentId` | `Integer` | The Document ID associated with the Segment |
| `versionId` | `String` | A digest hash uniquely identifying the document version. Used for tracking publishing changes. |
| `placementId` | `String` | The matched Placement that triggered the content display. Useful for debugging. |
## candu.sdk.content
Fired when content renders on the page: after the user matches the Segment and display rules, the content mounts and its styles load. There is no viewport visibility check, so content rendered below the fold or inside a hidden element still fires this event.
For Tours, this event can fire when the Tour loads even if a step's target element is not on the page yet. To count Tour Steps that were actually shown, use `candu.sdk.tour_step_tooltip`.
# Component Events
These are useful for tracking interactions. Component events always have a `nodeId` associated with them. Note that components do not have identifiers as they're a logical grouping of `Nodes`.
Component events have the following identifiers:
| Identifier | type | Description |
| :- | :- | :- |
| `contentId` | `String` | The Content that fired the event. |
| `segmentId` | `String` | The Segment that was matched against the user when the event fired. |
| `documentId` | `Integer` | The Document associated with the Segment. |
| `versionId` | `String` | A digest hash of the document uniquely identifying a specific version of the Document. Useful for tracking publishing changes. |
| `placementId` | `String` | The Placement that matched to trigger the Content. Useful for debugging and analytics. |
| `nodeId` | `String` | The specific node that fired a given event. `nodeId` are **not** uniques across documents, however the combination of `documentId` and `nodeId` is unique. |
| `nodeType` | `String` | The type of Node that fired the event. |
| `eventName` | `String` | \[Optional] The Interaction label associated with a given action inside the node. |
## candu.sdk.content.interaction
A generic interaction event. This event is emitted by components like `Button`, `Link`, `Card` and any other component where an interaction can be specified.
## candu.sdk.dismiss
A generic dismiss events. This action is emitted by `Modal` or `Card` when they are dismissed.
## Checklists
### candu.sdk.tutorial.checklist\_group\_complete
Event emitted once when all items in a Checklist have been completed.
Includes the following additional properties:
| Key | type | Description |
| :- | :- | :- |
| `title` | `String` | The Checklist title |
Includes the checklist `title` in the payload.
### candu.sdk.tutorial.checklist\_item\_state\_updated
Emitted when an individual checklist item's state changes. Please note that event-driven Checklists do not emit this event.
Includes the following additional properties:
| Key | type | Description |
| :- | :- | :- |
| `title` | `String` | The Checklist title |
| `state` | `String` | The Checklist state. Either `Done` or `NotStarted` |
Includes the checklist `title` in the payload,
## Flows
### candu.sdk.flow\_step
A Flow Step has been seen. This actions are emitted by`FlowStep`nodes when they are being displayed as part of a `Flow`.
## Form
### candu.sdk.form\_submit
A Form has been submitted. The `formId` will be included in the body, as well as an encoded payload of all the Form fields.
| Key | type | Description |
| :- | :- | :- |
| `name` | `String` | The Form name |
## Tour
### candu.sdk.tour\_step\_tooltip
A Tour Step has been viewed.
### candu.sdk.tour\_step\_dismissed
A step has been dismissed.
### candu.sdk.tour\_completed
The Tour has been completed.
## Hotspot
### candu.sdk.hotspot\_tooltip
A Tooltip has been opened.
### candu.sdk.hotspot\_beacon
A Tooltip beacon has been rendered.
### candu.sdk.hotspot\_dismissed
A Hotspot has been permanently dismissed.
### candu.sdk.hotspot\_group\_dismissed
All the Hotspots in a group have been dismissed.
# Experimentation events
## candu.sdk.impression
Tracks experiment variant views, including control group impressions.
A User has seen an Experiment Variant. This happens when there is a matching Placement. In the case of control group, an impression occurs anytime a Placement matches for another Variant.
The event has the following payload:
| Key | type | Description |
| :- | :- | :- |
| `contentId` | `String` | \[Optional] The Content being rendered. |
| `variantId` | `String` | The Variant to which the User was assigned to. |
| `placementId` | `String` | The Placement that was matched. |
# FAQs
Source: https://developers.candu.ai/docs/faqs
|
Topic
|
Answer
|
|
Security Protocols
|
* Role based permissioning, all data stored in AWS (Ireland)
* All Candu passwords are hashed & salted, staff cannot retrieve
|
|
Data Encryption
|
We use industry-standard end-to-end encryption methods. All customer data is encrypted in transit and is only accessible via TLS/SSL and at rest with AES256.
|
|
End-user Protection
|
* Every aspect of Candu is encrypted; we recommend [enabling identify verification.](https://docs.candu.ai/en/articles/5917940-enabling-identity-verification)
* Data is stored on AWS, stored data is encrypted using AES
|
|
Certifications
|
SOC2 Type 2; Annual PEN Tests
|
|
Dependability
|
Candu uses a CDN to publish content, all components in the SDK are wrapped in [error boundaries](https://reactjs.org/docs/error-boundaries.html)
|
|
GDPR Compliance
|
With data protection and privacy built into everything we do, Candu is fully GDPR-compliant. We meet stringent international security standards, and we undertake comprehensive audits of our policies, networks, and systems to keep your information secure. The below are up to date and reflect our GDPR readiness.
* [Terms of Use](https://www.candu.ai/terms-of-use)
* [Privacy Policy](https://www.candu.ai/privacy-policy)
* [DPA](https://www.candu.ai/dpa)
|
|
Page Speeds
|
The complete Candu package is around 113kb (unzipped) and loads sequentially after your page. The existing won’t be impacted, and the Candu content will load in near real-time with your page. Once viewed, the content is then cached as well.
|
|
SLAs
|
Maintain 99.9% in our API & frontend assets
* Monitored via 3rd party integration, performed each minute
* Performed on 7 different locations across the world
|
|
Staged SDK Releases
|
Candu only release updates to our CDN SDK after thorough testing in staging environments and stagger releases to our customer base.
|
# Get Data into Candu via the REST API
Source: https://developers.candu.ai/docs/get-data-into-candu-via-the-rest-api
Candu's REST API can be used to make data available for content targeting and customization. See our guide on how to use this data in segmentation.
## Authentication
Candu uses Token Bearer authentication via the HTTP `Authentication` header. To authenticate with Candu's API, you need to access your API KEY from [your workspace settings.](https://app.candu.ai/settings/workspaces#access-keys)
You can then access the API using a `Authorization: Bearer` token.
```text theme={null}
curl -X GET \
https://api.candu.ai/api/contentMetadata \
-H 'content-type: application/json' \
-H 'Authorization: Bearer [ADD_YOUR_API_KEY_HERE]
```
For example if your API key is `TestAPIKey:`
```text theme={null}
curl -X GET \
https://api.candu.ai/api/contentMetadata \
-H 'content-type: application/json' \
-H 'Authorization: Bearer TestApiKey'
```
### /api/eventWebhook
User traits and events can be sent into candu via our inbound webhook.
### Identify
To send attributes for a given user. Typically, things like name, email, organization, role in company.
```Text Batched Events theme={null}
curl -X POST \
https://api.candu.ai/api/eventWebhook \
-H 'content-type: application/json' \
-H 'Authorization: Bearer [YOUR_API_KEY]' \
--data '[
{
"type": "identify",
"userId": "[USER_ID]",
"traits": {
"email": "auser@example.com",
"location": "New York",
"isAdmin": true
},
"timestamp": "2025-04-22T15:58:02Z"
},
{
"type": "identify",
"userId": "[USER_ID]",
"traits": {
"email": "anotheruser@anotherexample.com",
"location": "London",
"isAdmin": false
},
"timestamp": "2025-04-22T15:58:02Z"
}
]'
```
```Text Single Event theme={null}
curl -X POST \
https://api.candu.ai/api/eventWebhook \
-H 'content-type: application/json' \
-H 'Authorization: Bearer [YOUR_API_KEY]' \
--data '
{
"type": "identify",
"userId": "[USER_ID]",
"traits": {
"email": "auser@example.com",
"location": "New York",
"isAdmin": true
},
"timestamp": "2025-04-22T15:58:02Z"
}
'
```
| Field | Required? | Description |
| :- | :- | :- |
| type | yes | The type of tracking event. In this case, "identify". |
| userId | yes | The user ID we wish to update. |
| traits | yes | A dictionary map of user properties. Strings, numbers and boolean values are supported. For dates, we recommend using the ISO 8601 format (with the seconds and Z for timezone).' |
| timestamp | no | Defaults to the current time. |
The response will be:
* 204 (No Content) for correct events submission and handling.
* 400 (Bad Request) for malformed events submission, with a list of the malformed events.
* In case of batched events, none of the correct events will be handled either.
* 500 (Internal Server Error) for errors in the handling of one of the events.
### Group
To send attributes for a given group. Typically, things like name, industry, domain, email, employees.
```Text Batched Events theme={null}
curl -X POST \
https://api.candu.ai/api/eventWebhook \
-H 'content-type: application/json' \
-H 'Authorization: Bearer [YOUR_API_KEY]' \
--data '[
{
"type": "group",
"groupId": "[GROUP_ID]",
"userId": "[USER_ID]",
"traits": {
"name": "Apple",
"domain": "apple.com",
"email": "support@apple.com",
"industry": "Technology",
"employees": 329,
"plan": "enterprise",
"total billed": 830
},
"timestamp": "2025-04-22T15:58:02Z"
},
{
"type": "group",
"groupId": "[GROUP_ID]",
"userId": "[USER_ID]",
"traits": {
"name": "Google",
"domain": "google.com",
"email": "support@google.com",
"industry": "Technology",
"employees": 158,
"plan": "pro",
"total billed": 516
},
"timestamp": "2025-04-22T15:59:02Z"
}
]'
```
```Text Single event theme={null}
curl -X POST \
https://api.candu.ai/api/eventWebhook \
-H 'content-type: application/json' \
-H 'Authorization: Bearer [YOUR_API_KEY]' \
--data '
{
"type": "group",
"groupId": "[GROUP_ID]",
"userId": "[USER_ID]",
"traits": {
"name": "Apple",
"domain": "apple.com",
"email": "support@apple.com",
"industry": "Technology",
"employees": 329,
"plan": "enterprise",
"total billed": 830
},
"timestamp": "2025-04-22T15:58:02Z"
}'
```
| Field | Required? | Description |
| :- | :- | :- |
| type | yes | The type of tracking event. In this case, "Group". |
| groupId | yes | A unique identifier for the group we wish to create or update. |
| userId | no | If present, also adds the user to the given group. |
| traits | no | A dictionary map of group properties. Boolean, numbers, strings values are supported. For dates, we recommend using the ISO 8601 format (with the seconds and Z for timezone).' |
| timestamp | no | Defaults to the current time. |
### Track
To track a custom event for a given user. These can be used in content targeting.
```text theme={null}
curl -X POST \
https://api.candu.ai/api/eventWebhook \
-H 'content-type: application/json' \
-H 'Authorization: Bearer [YOUR_API_KEY]' \
--data '
{
"type": "track",
"userId": "[USER_ID]",
"event": "Upgraded plan",
"properties": {
"amountPaidInUSD": 30,
"newPlan": "Business+"
},
"timestamp": "2022-01-20T11:21:02Z"
}
'
```
| Field | Required? | Description |
| :- | :- | :- |
| type | yes | The type of tracking event. In this case, "track" |
| userId | yes | The ID of the user the event belongs to |
| event | yes | The name of the event |
| properties | no | A dictionary map of event properties. Strings, numbers and boolean values are supported. |
| timestamp | no | Timestamp the event occurred. Defaults to the current time |
# Javascript API
Source: https://developers.candu.ai/docs/getting-started
Candu's Javascript API is accessible via the `window` object, using the `window.Candu` object.
## **Candu.init**
`Candu.init` a method used to initialize Candu.
At a high level, `Candu.init` performs the following actions:
1. Initialize an instance of Candu.
2. Talks to Candu servers to get a user's state.
`
Candu.init` takes only one parameter, an `init` object. This is the same object that you pass in when you install the script tag.
Here is how to call `Candu.init:`
```typescript theme={null}
window.Candu.init({
// Required: your client token
clientToken: 'YOUR_CLIENT_TOKEN',
// Optional: provide a User Id
userId: 'USER_ID_TO_TRACK',
// Optional: Traits provide a way to pass information about your users for segmentation and variables
traits: { email: 'noreply@candu.ai', name: 'Georgia' },
// Optional: One or more groups the user is a member of. Each group may have traits which are common across all users in a group
groups: [{ id: "group-1", traits: { name: "GROUP_NAME" } }],
// Optional: Only used for "secret" variables as they are never logged to a server.
variables: { customerSecret: 'my variable secret'},
// Optional: hmac secret for a given userId. Required if you turned on identity verification.
hmac: 'hmac computed using the userId',
// Optional: callbacks are used to add interactivity to your documents. See below for guide.
callbacks: { onButtonClick: () => 'callback' }
});
```
Please refer to the [Script Installation Guide](https://docs.candu.ai/en/articles/5908307-installing-candu) to see a full details about how to install Candu
## Candu.getEventing
`Candu.getEventing` returns a javascript object that you can use to send us additional eventing data, such as button clicks or page views. It's useful in case you want to track events that occur outside of Candu.
`Candu.getEventing` takes no parameters, and returns an object with the following interface:
```typescript theme={null}
interface Eventing {
identify: (userId: string, traits?: object) => void;
track: (eventName: string, properties?: object) => void;
page: (pageName: string, properties?: object) => Promise;
screen: (screenName: string, properties?: object) => void;
group: (groupId: string, traits?: object) => void;
}
```
Here is how to call `Candu.eventing:`
```text theme={null}
const eventing = window.Candu.getEventing();
eventing.track('cart.button.click', { amountPaidInUSD: 30 });
```
## Candu.tearDown
`Candu.tearDown` is used to destroy and teardown a client. This can be useful to:
1. Remove a users session and Candu content when a user logs out of your page.
2. Temporarily hide all Candu content during critical user flows (checkout processes, system maintenance notifications, native modals, etc.).
3. Free up browser resources in case you don't need Candu anymore on a page.
`Candu.tearDown` takes no parameters.
Here is how to call `Candu.tearDown`:
```typescript theme={null}
window.Candu.tearDown();
```
Calling `Candu.tearDown` is not necessary if a logout reloads the page.
> **Note:** After calling `tearDown()`, you'll need to call `Candu.init()` again to restore Candu functionality within the same browser session.
## Candu.getMembership
This call returns the Segment IDs that the current customer belongs to in [Candu Segmentation](https://docs.candu.ai/en/articles/5893679-segmentation-overview). Segment IDs correspond with individual segments configured within the Candu dashboard.
This can be used to determine if a customer falls in to a specific Candu Segment to provide supporting content.
```coffeescript TypeScript theme={null}
window.Candu.getMembership();
```
Example usage:
```coffeescript TypeScript theme={null}
window.Candu.getMembership().then((segments) => {
if (segments.contains('xlGqv7gQMY')) {
showAdditionalNavigation(); // external function to show extra supporting content
}
});
```
## Candu.refreshMembership
This call is used to force the Candu client to reload [Candu Segmentation.](https://docs.candu.ai/en/articles/5893679-segmentation-overview)
```typescript theme={null}
window.Candu.refreshMembership();
```
You should refresh membership if an event occurs that you expect to have updated Segment membership and want the customer to see this in real-time.
For example, firing a conversion event that would lead to seeing a different banner.
This may be combined with a call to eventing like this:
```typescript theme={null}
const afterEnterprisePurchase = () => {
const eventing = Candu.getEventing();
eventing.track('Purchased Enterprise Plan').then(() => {
Candu.refreshMembership();
// On-page Candu content that uses segmentation based off this event should now be updated
});
}
```
You should only need to do this if state has updated since Candu was initialized.
If you don't explicitly refresh membership then it will be refreshed on the call to `Candu.init`, typically on the next page load.
## Triggering Content Programmatically
For most use cases we recommend [placing content with the Candu Extension ](https://docs.candu.ai/en/articles/5916841-embedding-candu-content), but for advanced use cases you may need to trigger content programmatically.
You'll need to implement any conditional logic when setting up the trigger on your side, as they do not apply any placements, i.e. URL rules you have set up in Candu. Trigger content will still abide by Segmentation rules.
As a best practice, we recommend removing the trigger snippet from your code when you no longer want the content to be triggered as triggering content programmatically bypasses publish state.
### Candu.renderContent
To render a piece of Inline Content. You can target either an element or a CSS selector
```typescript theme={null}
window.Candu.renderContent({
// Mandatory: the slug of a content that you'd like to render.
slug: 'your-content-slug',
// Optional: a reference to the DOM element you would like to render the content inside
element: document.getElementById('candu-target'),
// Optional: a string containing the CSS selector you would like to render indo
selector: '#candu-target',
// Optional, used to specify if Candu Content should be added at the start, end or replace the target element
// Valid values are: 'Start' | 'End' | 'Replace'. Defaults to 'Start'
selectorLocation: 'End'
});
```
Content rendered into an element are added for the given page load, until the Element is removed from the DOM.
Selector based renders use DOM Observer APIs to listen for matches that occur later. The first match is always used.
Here is an example selector based renderContent call:
```typescript theme={null}
window.Candu.renderContent({
slug: 'your-content-slug',
selector: '#candu-target',
});
```
### Candu.triggerModal
Used to trigger Overlays, pop-ups and slide-outs. On-screen position is configured within the Candu Editor. Note: Modals can also be triggered on page load [guide](https://docs.candu.ai/en/articles/5916841-launching-candu-content#h_a3275d2f0c) or from Candu content [guide](https://docs.candu.ai/en/articles/6819690-triggering-overlays-from-candu-cta).
```typescript Typescript theme={null}
window.Candu.triggerModal({ slug: 'your-modal-slug' })
```
### Candu.triggerTour
Used to trigger Tours that guide users within your product. Individual Tour Step locations can be configured within the Candu Editor. Note: Tours can also be triggered on page load or from Candu content [guide](https://docs.candu.ai/en/articles/9167026-triggering-tours).
```typescript theme={null}
window.Candu.triggerTour({ slug: 'your-tour-slug' })
```
### Candu.triggerHotspotGroup
Used to trigger a group of Beacons that can be clicked to open Tooltips. Beacon locations are configured within the Candu Editor. Note: Hotspots can also be triggered on page load or from Candu content [guide](https://docs.candu.ai/en/articles/9167077-triggering-hotspots).
```typescript theme={null}
window.Candu.triggerHotspotGroup({ slug: 'your-hotspots-slug' })
```
# Handling SDK failure
Source: https://developers.candu.ai/docs/handling-failure
At Candu, we take reliability very seriously. While we strive to have the highest availability, we recognise that our systems sometimes will fail.
This document is discussed to help you understand all the possible ways in which Candu can fail, and how to handle them so you can provide your users the best experience possible.
We'll be listing all our potential points of failures from the least likely to the most likely. An overview about Candu's client architecture can be found [here](/docs/architecture-overview).
This document is only concerned with discussing SDK potential failures. For a more generic guide, please refer to our [Performance & Reliability](/docs/reliability-availability) guide.
# S3 Failure
Our assets are stored on S3, in EU West 1. S3 has an [extremely high avaliability](https://aws.amazon.com/s3/storage-classes/), up to 99.99%. The only build in safeguard that Candu offers is is [caching](/docs/caching).
If customers want to safeguard for extreme failure, please refer to this guide.
# CDN failure
At Candu, we use S3 and Cloudflare to distribute our assets. You can read more about our CDN and caching strategy [here](/docs/caching). Cloudflare offers 100% [Business SLA](https://www.cloudflare.com/business-sla/) on their services.
# API Failure
The most likely types of failures are due to API. For SDK APIs we rely on high availability, managed databases such as DynamoDB and MemoryDB to reduce the risk of downtime as much as possible, and to provide extremely fast access times.
In case of failure though, our SDK will be handling gracefully by simply rendering content as if there was no state.
For example, if you have multiple content, but we fail to elaborate which segment you belong to, we assume that you belong to the `Everyone` segment.
Similarly, forms and other stateful components will appear without state.
# Handling extreme failure
At Candu, we want to make sure we can provide the highest availability to our customers. As such, we have build in ways to make sure that content can be rendered even in case S3 or Cloudflare were to fail, down below.
The implications of a CDN or API failure is that content would not be rendering. Our SDK would be handling such [failure gracefully](/docs/reliability-availability), without throwing errors.
SDK failure or extreme lag can be detected by using the [DOM API](/docs/dom-api) to check if content has been rendered within the desired timeframe.
If not, then it is possible to reinitialise Candu's SDK in a stateless option, which doesn't rely on any external API or config, but will simply render any document that will be passed in. At that point, the customer can load a document from a backup source to provide a fallback experience.
# Installing Candu
Source: https://developers.candu.ai/docs/installing-candu
## Installation
There are three core steps to installing Candu [(full guide here)](https://docs.candu.ai/en/articles/5908307-installing-candu):
**Step 1 – Get your Client Token**
1. Visit [https://app.candu.ai/settings](https://app.candu.ai/settings)
2. Scroll to **Access Keys**
3. Make a note of your **Client Token**
**Step 2 – Add the Script Tag**
Add the following to your application — choose the approach that fits your setup
Replace `YOUR_CLIENT_TOKEN` with the token from Step 1 and `CONTEXTUAL_USER_ID` with a unique ID for the logged-in user (e.g. the user ID from your database or auth system):
```html HTML theme={null}
```
```html HTML (React) theme={null}
```
**Step 3 – Whitelist Domains**
Whitelist the domains you are going to be using Candu on.
1. Depending on your Content Security Policy (CSP) you may also need to whitelist the following URLs:
1. `https://api.candu.ai/`
2. `https://cdn.candu.ai/`
3. `https://media.candulabs.com/`
4. *Optional* `https://sentry.io/` (Not required for functionality; used to capture errors)
**Please note:** You have the option to set up multiple [Workspaces](https://docs.candu.ai/en/articles/5894648-candu-workspaces) in Candu to separate and organize content, e.g., a workspace for your Staging/Sandbox environment and one for Production. Each workspace has a separate Candu script tag, whitelisting, and segmentation setup.
## Optional Steps
### Send user data and events to improve personalization
To use Candu's personalization features, you'll need to send user traits and events into Candu.
[How to send user traits and events into Candu](/docs/segmentation-overview)
### Enable Signed Identities
If you are sending personally identifiable information (PII), we recommend setting up [signed identities](https://docs.candu.ai/en/articles/5917940-enabling-identity-verification) for increased security and guaranteed event attribution.
# Performance & Reliability
Source: https://developers.candu.ai/docs/reliability-availability
At Candu, we care deeply about providing the highest availability and reliability to our customers. Because Candu is meant to be a seamless part of your UI, our explicit objective is that Candu must be as or more reliable than any of our customers' infrastructures. Of course, we never want our app to go down, but more importantly, we never want anything to negatively impact your users' experience within your product.
This article discusses all the architectural decisions that we have made and implemented in order to provide our customers with a highly reliable product. You can learn more about Candu's [Architecture here](/docs/architecture-overview).
To read how we handle failure in the SDK, please read [this guide.](/docs/handling-failure)
## Backend Infrastructure
Candu is deployed over AWS, and we run most of our servers in ECS. We use blue-green deployments powered by a custom-made framework. At any given point, we can roll back to any commit within 3 minutes.\
We also have the ability to create a staging environment in less than a minute for any commit that is pushed to our backend. Developers can then test any change in a production-like environment.
For databases, we use a combination of DynamoDB and RDS across multiple hosting zones to ensure maximum uptime and reliability.
High throughput data processing code is hosted using AWS Lambda to ensure the highest availability and scalability levels.
Finally, we use a message-driven architecture to ensure that critical customer data is processed at least once.
## Frontend Infrastructure
In order to provide high availability and fast delivery, Candu uses a CDN to publish content.
Whenever a user edits content in our dashboard, the changes are saved on our servers.
Once content has been published, Candu uploads a version of that content to the CDN. We use this publishing mechanism in order to:
1. Ensure that you can safely edit content in a draft state before publishing.
2. Increase the upload speed and availability of all content that you create.
3. Provide a versioning process and audit trail for any content.
All of the assets served through Candu to your customers are hosted on an enterprise-grade CDN.
We use a CDN for the following reasons:
1. CDNs have extremely high availability and reliability. We selected S3 + Cloudflare as our primary vendors.
2. CDNs are distributed and geographically close to our customers, meaning we can serve content quickly.
## SDK
The Candu SDK is installed within your application to provide dynamic segmentation and user analytics, and to render UI.
The SDK's main functionalities are:
1. Rendering Content
2. Collecting analytics via eventing
Our SDK is engineered to handle multiple failure points. The first request that is executed when initializing the SDK is retrieving the "customer segment." This is the only request from the SDK that is not stored on the CDN. Customer segments are cached to local storage in case the network fails.
If a network call fails or is too slow for any reason, then (to create a consistent user experience), the customer will see whatever content version they saw last. If the network call fails the first time, before it has been cached, then the customer will default to the Everyone Segment.
After the SDK requests Segment membership, Candu fetches the Content. These are also cached to prevent further network failures, as an additional failsafe, as they will already have been hosted on the CDN.
In the worst-case scenario where AWS S3 or Cloudflare fails and there is no local content cached, then no content will be served and the page remains intact, looking as though Candu was never installed.
## Error Handling
All components (e.g., Content, Segments, etc.) in the SDK are wrapped with [error boundaries](https://reactjs.org/docs/error-boundaries.html) to prevent JavaScript-related errors from propagating outside the Candu SDK and impacting our clients. If the error boundaries receive any errors, those are logged in the Candu tracking system.
If Candu encounters a JavaScript error in customer code or if an error happens anywhere in the Candu SDK, those errors are logged in the Candu tracking system for immediate review. If for any reason there is an undetected error, Candu automatically drops rendering and will not display any content in order to protect page performance.
## Code Quality
Before release, each new SDK version needs to pass an extensive and continuously expanding set of unit and integration tests to eliminate any potential regression tests. Additionally, we aim to reach 100% coverage using TypeScript to minimize type unsafe errors and to help developers with integrating the SDK into their projects.
## Versioning
In case a breaking change is identified on an SDK release, we bump versioning for that release according to SemVer. This should prevent accidental installation of the SDK without proper migration steps in place.
## SLAs
At Candu, we take our SLA and partner operations extremely seriously. We strive to maintain a 99.9% SLA in all of our APIs & frontend assets.\
SLA monitoring is done through 3rd party integration monitoring. We currently ping 10+ APIs for uptime, as well as other critical aspects of our infrastructure that we use to provide services.
All the tests are performed from 7 different locations around the world (Canada Central, Ohio, Oregon, Sydney, Tokyo, Frankfurt, London) to ensure we maintain availability within and throughout different regions.\
All critical integration tests are performed each minute.
If any alerts were to fail, our team would be notified immediately as outlined in our escalation policy.
# Security Overview
Source: https://developers.candu.ai/docs/security-overview
Candu is committed to the highest standards of security. We take responsibility for managing your customer data securely.
If you have any questions or want to report any security issue, please contact us at [security@candu.ai](mailto:security@candu.ai).
## Data management
Learn about how Candu handles personal information and how we delete and export customer data:
### Handling personal information
Candu doesn't require any personally identifiable information (PII) to be passed to the service, nor do we actively collect any PII from our customers.
### Deleting customer data
We believe customers have the right to be forgotten. In accordance with GDPR, Candu will delete all of your customer data within 30 days of receiving a written request.
### Exporting customer data
In accordance with GDPR, Candu will provide an export of customer data in JSON format within 30 days of receiving a written request.
## Data security
We follow industry-standard end-to-end encryption methods and use best-in-class vendors for cloud and application security. Each quarter, we review our security practices to keep them up-to-date.
## End-to-end encryption
Every aspect of the Candu application is encrypted. Our servers enforce HTTPS protocol by using TSL 1.2. Internally, our servers communicate exclusively using HTTPS.
Our data is stored entirely on AWS services. We encrypt stored data using AES encryption (provided by AWS services). Any server-side secret is stored and accessed via AWS KMS. We rotate sensitive keys and expire critical keys.
All backups are encrypted and stored using AES-256 in secure cloud locations within the EU.
## Cloud security
At Candu, we have taken all necessary precautions to maintain our AWS cloud as securely as possible.
We mandate strong passwords and 2FA to access our AWS account. Our engineers are granted roles and permissions using a least privilege principle.
We use encrypted SSH keys to access our bastion servers. Our servers do not have a public IP unless strictly necessary.
Our services also run on a least privilege principle.
All data is always stored exclusively within the EU.
We have multiple levels of redundancy and backup processes to minimize data loss in case of an attack or system failure.
## Application security
Candu account passwords are hashed and salted, and our staff is not able to view or retrieve them. To protect your password, we use a symmetric block cipher (Blowfish) of at least 12 salt rounds. If you lose your password, it cannot be retrieved; it must be reset.
The entire Candu application is encrypted with HTTPS.
# Segmentation Overview
Source: https://developers.candu.ai/docs/segmentation-overview
### Personalization Features
Candu has two core features that allow you to create personalized content experiences:
* [Segmentation: ](https://docs.candu.ai/en/articles/5893679-segmentation-overview)using data to create groups of users that you can target different content to. For example, users who are in a trial vs. those that are power users or users that are admins vs. users that are guests.
* [ Variables:](https://docs.candu.ai/en/articles/5901143-using-variables-in-content) using data in text components (like email marketing) so you can create dynamic typography like 'Hi \{FIRST NAME}' or even pass through data if you wanted to display metrics or statistics e.g. 'Average project count this month \{NUMBER OF ACTIVE PROJECTS}.
### Data Types
To use either of these features you have the option of sending us two types of data:
* **User Traits:** this is data such as role type, account name, first name and email address.
* **User Events:** this is data linked to product actions that a user has done such as invited team member, has active project and installed the Chrome Extension.
### Options to Send Candu Data
There are a number of ways you can send data into Candu
1. Directly via the [install script tag](https://docs.candu.ai/en/articles/5917572-setting-up-segmentation#h_ecf2ab68fb)
2. Via [API ](/docs/get-data-into-candu-via-the-rest-api)
3. Via third party integration like:
1. [Segment.com](https://docs.candu.ai/en/articles/6007476-segment-com-destination)
2. Hubspot
3. [Salesforce](/page/salesforce-data-source-setup) (native integration: Account and Contact fields sync into Candu as traits)
Please note, we only accept user level data at the moment, not account level information.
We also recommend setting up Signed Identities if you send us personal information about your users to ensure your user data is as secure as possible. **Note**: Only workspace Owners and Admins can enable/disable Signed Identities.
# Setting up Outgoing Webhooks
Source: https://developers.candu.ai/docs/setting-up-outgoing-webhooks
Candu supports both incoming and outgoing webhooks to push and consume eventing data.
For Candu enterprise plans, we support consuming customer eventing data via webhooks.
## Configuring a new webhook
To create a new webhook you need to go to Settings > Integrations > Outgoing Webhooks > Setup a new webhook from within the Candu dashboard.

Webhooks take in the following configuration:
### URL
This is the end-point that you've configured to consume Candu events, this would typically be a server you're hosting or a third party service that allow webhook consumption functionality, such as [Zapier](https://docs.candu.ai/en/articles/6903949-webhooks-candu-zapier-your-app-of-choice), [Make ](https://docs.candu.ai/en/articles/6921876-webhooks-candu-make-app-of-choice)or [Slack.](https://docs.candu.ai/en/articles/7436902-outgoing-webhooks-candu-to-slack)
### Name
This is a friendly name for your webhook that allows you to identify from the settings dashboard the webhook you're configuring.
### Webhook format
The webhook format is responsible for how eventing HTTP request payloads are formatted. Two formats are supported currently, Default and Slack.
The Default format will send requests with a JSON payload containing a `payload` field at the top-level with a Candu customer event in this cURL format:
```text theme={null}
curl --request POST \
--url http://your-defined-webhook-endpoint.com/endpoint \
--header 'Content-Type: application/json' \
--data '{
"payload": {
"id": "3a3da0f6-b9bb-444a-b59d-275bc057bd68",
"anonymousId": "25c27067-9b69-41ab-99c4-5c69dc0df8ff",
"userId": "candu-demo-user",
"type": "Track",
"context": {
"library": {
"name": "JsClient",
"version": "0.9.28"
},
"page": {
"path": "/",
"url": "https://demo.candu.ai/",
"title": "Candu Showcase",
"search": "",
"referrer": ""
},
"screen": {
"width": 800,
"height": 600
},
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246",
"timezone": "Europe/London",
"locale": "en-GB",
"sdk": {
"name": "@candulabs/cdn",
"version": "0.9.28"
}
},
"sentAt": "2023-01-18T15:28:02.063Z",
"receivedAt": "2023-01-18T15:28:02.326Z",
"eventName": "candu.sdk.content.interaction",
"properties": {
"eventName": "Demo Content - Open Candu AI button clicked",
"versionId": "81dc9bdb52d04dc20036dbd8313ed055",
"segmentId": "Everyone",
"id": 1234,
"category": "Native",
"contentId": "nrpHFcRlmW",
"documentId": 1234,
"trigger": "OnClick"
},
"version": 2
}
}'
```
The Slack format will send a more user-friendly breakdown of the event, with bespoke formatting based on the topic the customer event belongs to, and is currently intended only for Slack[ incoming webhook consumption.](https://api.slack.com/messaging/webhooks)

### Webhook Topic
We offer the following topics to subscribe to: Content Views, Content Interactions, and Form Submission events.

### Content Views
A Content View event is triggered whenever a customer views a piece of Candu content. You would rely on the properties.slug field to reconcile which content is receiving new content views and the userId field to track the end user who is performing the view.
You can find a piece of content's slug from within the dashboard by going to Content > Choose your content > Settings.

Here's an example content view event payload:
```text theme={null}
{
"id": "34519762-2f78-4e99-b5d2-aaa5079857c5",
"anonymousId": "25c27067-9b69-41ab-99c4-5c69dc0df8ff",
"userId": "test-user",
"type": "Screen",
"context": {
"library": {
"name": "JsClient",
"version": "0.9.27"
},
"page": {
"path": "/",
"url": "https://demo.candu.ai/",
"title": "Candu Showcase",
"search": "",
"referrer": ""
},
"screen": {
"width": 1792,
"height": 1120
},
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246",
"timezone": "Europe/London",
"locale": "en-GB",
"sdk": {
"name": "@candulabs/cdn",
"version": "0.9.27"
}
},
"sentAt": "2023-01-17T17:19:54.311Z",
"receivedAt": "2023-01-17T17:19:54.434Z",
"screenName": "candu.sdk.content",
"properties": {
"versionId": "81dc9bdb52d04dc20036dbd8313ed055",
"segmentId": "Everyone",
"slug": "demo-content",
"contentId": "nrpHFcRlmW",
"documentId": 32470
},
"version": 2
}
```
### Content Interactions
A Content Interaction event is triggered when a customer interacts with an interactable component with-in your Candu content.
properties.eventName is the interaction label specified in the Candu Editor associated with the content interaction.
To see the interaction label of an interactable component go to the editor, click on the component, and go to the interactions tab. You will see the interaction label there.

```text theme={null}
{
"id": "3a3da0f6-b9bb-444a-b59d-275bc057bd68",
"anonymousId": "25c27067-9b69-41ab-99c4-5c69dc0df8ff",
"userId": "candu-demo-user",
"type": "Track",
"context": {
"library": {
"name": "JsClient",
"version": "0.9.28"
},
"page": {
"path": "/",
"url": "https://demo.candu.ai/",
"title": "Candu Showcase",
"search": "",
"referrer": ""
},
"screen": {
"width": 800,
"height": 600
},
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246",
"timezone": "Europe/London",
"locale": "en-GB",
"sdk": {
"name": "@candulabs/cdn",
"version": "0.9.28"
}
},
"sentAt": "2023-01-18T15:28:02.063Z",
"receivedAt": "2023-01-18T15:28:02.326Z",
"eventName": "candu.sdk.content.interaction",
"properties": {
"eventName": "Demo Content - Open Candu AI button clicked",
"versionId": "81dc9bdb52d04dc20036dbd8313ed055",
"segmentId": "Everyone",
"id": 1234,
"category": "Native",
"contentId": "nrpHFcRlmW",
"documentId": 1234,
"trigger": "OnClick"
},
"version": 2
}
```
### Form Submissions
A Form Submission event is triggered when a customer submits a form. The properties.formName is the name of the form associated with the submission event. The properties property also contains a key-value mapping of the user's form inputs.
```text theme={null}
{
"id": "288cc201-9f2e-43a2-95fa-b7df5dd13eae",
"anonymousId": "3f7ee2d6-a306-42ac-97b4-f865630c2aad",
"userId": "candu-demo-user",
"type": "FormSubmission",
"context": {
"library": {
"name": "API",
"version": "latest"
},
"source": "UserGenerated"
},
"sentAt": "2023-01-18T15:27:06.568Z",
"receivedAt": "2023-01-18T15:27:06.928Z",
"eventName": "Demo Content - Contact us_responded",
"properties": {
"formName": "Demo Content - Contact us",
"Demo Content - Contact us_Email address": "mike@candu.ai",
"Demo Content - Contact us_Write a message": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam finibus tempor nisi at tristique.",
"formResponseId": "XT4BJUYTw3",
"Demo Content - Contact us_Name": "Mike",
"formId": "9Wneb7Nk1qtTCEuGDJa0L"
},
"version": 2
}
```
## Troubleshooting your outgoing webhook
### Viewing webhook event logs
When Candu sends customer eventing data to your end-point, it expects a 2xx HTTP response code from the server.
If the request times out, or we get a non-2xx response code, we persist error logs, with the status code we received and the payload we got back. These event logs can be accessed by viewing your webhook in the dashboard.

## Additional troubleshooting
If event logs aren't coming through as you'd expect, it's worthwhile checking the following:
1. If you have identity verification enabled, ensure it's configured correctly.
2. Ensure you have correctly [installed Candu](https://docs.candu.ai/en/articles/5908307-installing-candu)
3. Ensure that your webhook belongs to the same workspace that your installation script's client token belongs to (go to Settings > Workspaces > Access Keys > Client Token to see the client token for your current workspace).
4. Ensure that your webhook has a status of Enabled.
# Signed Identities
Source: https://developers.candu.ai/docs/signed-identities
If you are going send Candu personally identifiable information (PII), then we highly recommend setting up identity verification. It protects you and your users from having data passed to third parties.
There is a full guide on this [here. ](https://docs.candu.ai/en/articles/5917940-enabling-identity-verification)
# SSO Setup - Okta
Source: https://developers.candu.ai/docs/sso-setup-okta
## You will need
* Access to manage Applications within your Okta instance
* A **connection identifier**, provided to you by your Candu Success Manager
## 1. Set up Candu as a new Application within Okta
### Create SAML Integration
Navigate to your Okta management interface and click Create App Integration.
Replace \{CONNECTION\_IDENTIFIER} below with one provided to you by Candu.

Choose SAML 2.0

Configure your app name, for example, `Candu-SSO`, you may want to follow internal naming conventions.

### Configure SAML settings
Single sign-on URL:
```text theme={null}
https://candu.eu.auth0.com/login/callback?connection={CONNECTION_IDENTIFIER}
```
Audience URI:
```text theme={null}
urn:auth0:candu:{CONNECTION_IDENTIFIER}
```

### Configure Attribute Statements
Configure mappings for `email`, `name` and `family_name`

Once these are set you may press next and save the configuration. You can enter feedback survey details if you wish.
## 2. Provide Candu with sign in URL & signing details
Please provide us with the following from the "Sign On" section of the configured application:
* **Sign on URL**

* **SAML Signing Certificates** - Downloaded from the Sign On section

* **Sign Request Algorithm** - Please confirm the "Type" value from the above. In this case SHA-2
We'll get this set up and then can test the integration ahead of switching over to the singular way to log in.
## Note: Mapping user roles
Candu does not currently support mapping user roles. New users will be on boarded as Editors but permissions for those users can be set once they log in.
Existing users signing in with SSO for the first time will retain their roles.
# Testing & Previewing Content
Source: https://developers.candu.ai/docs/testing-and-previewing-content
How to see your content as a real user before launch, force it to show, and check why it isn't appearing.
Use these steps to test content in your own app before your users see it.
## 1. Publish to a "just me" segment
Create a segment that only matches you (for example a User ID or email condition with your own value), and publish the content to that segment. This is the most reliable test because it uses the real SDK, placement and URL rules.
## 2. Find the user ID Candu sees for you
Open your browser console on a page where Candu is installed and run:
```js theme={null}
Candu.providerProps
```
Check that the `userId` (and traits) match what your test segment expects. Shared test accounts can have more than one user ID.
## 3. Force a piece of content to show
* **Tours:** add `?canduTour=YOUR-TOUR-SLUG` (or `#canduTour=YOUR-TOUR-SLUG`) to the page URL, or call `Candu.triggerTour({ slug: 'your-tour-slug' })`.
* **Modals:** from your app code or the console, call `Candu.triggerModal({ slug: 'your-modal-slug' })`.
* **Inline content:** render it into an element with `Candu.renderContent` (see [Javascript API](/docs/getting-started)).
Programmatic triggers ignore URL placement rules, but segment targeting still applies. The slug is under the content's **Settings > General**.
## 4. Refresh segment membership after changing data
If you change traits or send an event during the session, call:
```js theme={null}
Candu.refreshMembership()
```
so conditions, checklists and targeting re-evaluate without a page reload.
## 5. Things that behave differently in tests
* **Editor preview doesn't fire webhooks.** To test a form-response webhook, publish to your "just me" segment and submit in the live app.
* **Publishing takes a few minutes to reach the browser.** Content and placements are cached for up to 5 minutes (see [CDN & Caching](/docs/caching)).
* **"Until dismissed" is remembered per user.** If you dismissed it once, it won't show again for that user, even after republishing. Use a fresh test user or a new piece of content.
## Still not showing?
Check, in order: the content is published, the placement URL rule matches the page, your user matches the segment, you haven't dismissed it, the SDK is installed in this environment, and the target selector exists on the page. See [Troubleshooting Content Not Showing Up](https://docs.candu.ai/en/articles/5908444-troubleshooting-content-not-showing-up).
# Using Form Data to Populate your Product
Source: https://developers.candu.ai/docs/using-form-data-to-populate-your-product
In some instances you may want to capture data using a Candu Form and then pass that data into your product. For example when onboarding new users you might create forms to collect essential information to configure their account so you can tailor your products content or recommendations. Examples include:
* The name of a project, organization or store
* Preferred language
* Name of their profile or team
There are two ways to get the data: in the browser with `onFormSubmit`, or on your server with webhooks.
## Option 1: In the browser with onFormSubmit
Pass an `onFormSubmit` function when you initialize Candu. It runs on every Candu form submission in that page session and receives the form's details and the submitted values (field label to value), so you can check which form it was and use the values in your own code.
```typescript theme={null}
window.Candu.init({
clientToken: 'YOUR_CLIENT_TOKEN',
userId: 'USER_ID_TO_TRACK',
options: {
onFormSubmit: (formInfo, formData) => {
if (formInfo.name === 'Onboarding: project name') {
saveProjectName(formData['Project name']); // your own function
}
// return false to cancel the submission
},
},
});
```
Use this when the data only needs to reach the page the user is on. Use webhooks (below) when your backend needs it reliably.
## Option 2: On your server with webhooks
1. Create your Form in Candu
* Guide to this is [here. ](https://docs.candu.ai/en/articles/6827350-creating-candu-forms)
2. Configuring Webhooks for Form Responses
* Guide to this is [here.](https://docs.candu.ai/en/articles/6921899-outgoing-webhooks-form-response-data)
* Submissions made in the editor preview don't fire webhooks. Test by publishing to a segment that only contains you and submitting in your live app.
3. Handling Webhook Requests:
* In your product, you need to create a webhook endpoint to receive the data from Candu.ai.
* Set up an endpoint in your backend application that will listen for incoming requests from Candu.ai. This endpoint should be able to accept \`POST requests.
* Depending on the programming language and framework you're using, you can set up a route or controller to handle the incoming webhook requests.
4. Parsing and Processing the Webhook Data:
* When a webhook request is received at your endpoint, you'll need to extract and process the relevant data from the request payload.
* Parse the JSON or form-encoded data sent by Candu.ai to extract the form field values.
* Validate and sanitize the data as per your product's requirements.
* You can then perform any additional processing or transformation on the data if needed.
5. Populating the Data in Your Product:
* Once you have extracted and processed the data, you can use it to populate your product's internal database or perform any other desired actions.
* This could involve storing the form data in a database, triggering specific actions based on the form submissions, or displaying the captured data in your product's user interface.
Remember, the specifics of implementing webhooks and processing the data will depend on the programming language, framework, and infrastructure you are using for your product. However, the general steps outlined above should give you a good starting point for capturing form data from Candu and populating it in your own product.
# Candu developers
Source: https://developers.candu.ai/index
Install Candu, personalize experiences, and connect your application.
Build Candu into your application with installation guides, SDK documentation, and integration references.
> **[Architecture overview](/docs/architecture-overview)**
>
> Understand how the SDK, CDN, content, and analytics fit together.
> **[Core entities](/docs/entities)**
>
> Learn about content, placements, segments, documents, and nodes.
> **[Candu help center](https://docs.candu.ai/en/)**
>
> Find product guides and help for building experiences.
> **[Open Candu](https://app.candu.ai/login)**
>
> Sign in to manage your content and integrations.
# Salesforce Data Source Setup
Source: https://developers.candu.ai/page/salesforce-data-source-setup
Set up Salesforce authentication, permissions, and data synchronization with Candu.
> 🚧 We're in the process of improving this guide and expect a little bit of back and forth as we make sure it's right for all Salesforce versions. Any feedback you might have would be sincerely appreciated.
## Initial setup & authentication
Quick steps:
1. [Confirm Company name](#1-confirm-company-name)
2. [Candu issues certificate](#2-candu-will-issue-a-certificate)
3. [Integration Profile Setup](#3-integration-profile-setup)
4. [Integration User Setup](#4-integration-user-setup)
5. [Client App Setup](#5-client-app-setup)
6. [Candu sets up your sync](#6-candu-team-sets-up-your-sync)
7. [Confirm mapped fields and Enable](#7-confirm-mapped-fields-and-enable)
## 1. Confirm Company name
Candu will issue a signing certificate for use in the integration flow, for this we'll need to confirm the company name:
Organization Name - usually in Company Settings → Company Information

## 2. Candu will issue a certificate
Based off the provided company name, Candu will generate a certificate and private key for use accessing the API. You'll upload the certificate in step 5.
Note: The certificate will be issued with the email `engineering+{companyName}@candu.ai`.
## 3. Integration Profile setup
Create a new profile to be used for the integration

Ensure the created profile has the following permissions:
1. **Administrative Permissions**
1. API Enabled

2. **Standard Object Permissions**
1. Accounts: Read, View All Records, View All Fields
2. Contacts: Read, View All Records, View All Fields


## 4. Integration User Setup
Create a Candu User, with email: `engineering+{companyName}@candu.ai` and associate the above Profile to this User.

Note: this email must match the certificate generated in step 2.
## 5. Client App Setup
Next we'll set up an External Client App - usually in Apps → External Client Apps → External Client App Manager
It should be configured as follows:
1. **Basic Information**
1. Contact Email: [engineering@candu.ai](mailto:engineering@candu.ai)

2. **API (Enable OAuth Settings)**
1. Enable OAuth
3. **App Settings**
1. Callback URL: [https://app.candu.ai/salesforce/auth/callback](https://app.candu.ai/salesforce/auth/callback)
2. OAuth Scopes
1. Access Headless Passwordless Login (`pwdless_login_api`)
2. Manage user data via APIs (`api`)
3. Perform requests at any time (`refresh_token`, `offline_access`)

1. **Flow Enablement**
1. Enable JWT Bearer Flow
1. Upload the Candu certificate
2. **Security**
1. Check: Require secret for Web Server Flow
2. Check: Require secret for Refresh Token Flow
3. Uncheck: Require Proof Key for Code Exchange (PKCE) extension for Supported Authorization Flows
1. We do not support PKCE at the moment

Back in External Client App Manager, click on the newly created App.
In **Policies**, click Edit (located on the right of the tab)
1. **Oauth Policies** - Set Permitted Users: Admin approved users are pre-authorized
2. **App Policies** Once Oauth Policies is set to pre-authorised, add the Profile we created earlier to **Selected Profiles**

Next, within the newly created app, click **Settings** → **Oauth Settings**, then click **Consumer Key and Secret**

Take a note of the Consumer Key on the following screen. We do not require the Consumer Secret

## 6. Candu team sets up your sync
This step is not currently self-serve. The Candu team will set up your Workspace with the correct Salesforce endpoints.
For this, please provide us with the following information:
1. Your Salesforce authentication host URL, for example:
1. [https://login.salesforce.com](https://login.salesforce.com) - usually it's this for cloud managed instances
2. Your Salesforce token and query URLs, for example:
1. `https://orgfarm-06fe5fea5a-dev-ed.develop.lightning.force.com/services/data/v63.0/token`
2. `https://orgfarm-06fe5fea5a-dev-ed.develop.lightning.force.com/services/data/v63.0/query`
3. The Consumer Key from step 5
## 7. Confirm Mapped Fields and Enable
Once initial set up is performed, you'll be able to manage your integration via the Candu dashboard.
1. Configure mapping IDs for contacts and accounts.
2. Set up traits you'd like to import
3. Confirm details enable

## After setup
### Initial sync
The first sync after you enable the integration can take 24 to 48 hours to complete. After that, Candu syncs on the schedule you choose in the integration settings.
### Adding new Salesforce fields
You don't need a resync or a support request to bring in fields you add to Salesforce later.
1. In Candu, go to **Settings → Integrations → Salesforce → Configure Fields**.
2. New Account and Contact fields appear in the field list right away.
3. Map each new field to a Candu trait and save.
Candu syncs only the fields you've mapped. New mappings are included the next time the scheduled sync runs, and you can then use them in Segments like any other trait.