Installing Candu
Learn how to embed the Candu SDK, whitelist your domains, and verify the installation in less than five minutes.
Installation
There are three core steps to installing Candu (full guide here):
Step 1 – Get your Client Token
- Visit https://app.candu.ai/settings
- Scroll to Access Keys
- 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):
<script>
(function(d, params){
var script = d.createElement('script');
script.setAttribute('src', 'https://cdn.candu.ai/sdk/latest/candu.umd.js?token=' + params.clientToken);
script.onload = function () {
Candu.init(params);
}
d.head.appendChild(script);
})(document, {
userId: 'YOUR_USER_ID',
clientToken: 'YOUR_CLIENT_TOKEN',
});
</script><!-- in application header -->
<script src="https://cdn.candu.ai/sdk/latest/candu.umd.js?token=YOUR_CLIENT_TOKEN"></script>
<script >
// within your application at an appropriate time, once userId and email have been fetched:
useEffect(() => {
if (userId) {
Candu.init({
userId: CONTEXTUAL_USER_ID,
clientToken: YOUR_CLIENT_TOKEN,
traits: {
email: userEmail,
},
});
}
}, [userId]);
</script>Step 3 – Whitelist Domains
Whitelist the domains you are going to be using Candu on.
- Depending on your Content Security Policy (CSP) you may also need to whitelist the following URLs:
https://api.candu.ai/https://cdn.candu.ai/https://media.candulabs.com/- Optional
https://sentry.io/(Not required for functionality; used to capture errors)
Please note: You have the option to set up multiple 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
Enable Signed Identities
If you are sending personally identifiable information (PII), we recommend setting up signed identities for increased security and guaranteed event attribution.
Updated 18 days ago
