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

  1. Visit 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):

<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.

  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 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.