Script-set-up

This document describes recommended practices for deploying and configuring the script.

1. Basic Installation

On all pages where you want to track user actions, insert the following snippet before the closing </head> tag:

<script>
  (function (w, d, s, l, u, i) {
    w[l] = { project_url: u, project_id: i };
    var f = d.getElementsByTagName(s)[0];
    var j = d.createElement(s);
    var t = new Date().getTime();
    j.async = true;
    j.type = 'module';
    j.src = 'https://cdn.carecloud.cz/engagement/script.js?t=' + t;
    f.parentNode.insertBefore(j, f);
    w.ccce = w.ccce || [];
  })(window, document, 'script', 'ccce_config', '${YOUR_PROJECT_URL}', '${YOUR_EXTERNAL_APPLICATION_ID}');
</script>

We recommend loading the script using Google Tag Manager while ensuring the appropriate cookie settings.

Recommendations

  • The script loads asynchronously (already set).
  • Always place the snippet at the end of the head, so the ccce interaction queue is created.
  • Configure your own ${YOUR_PROJECT_URL} and ${YOUR_EXTERNAL_APPLICATION_ID}.

2. Identifying Logged-in Users

To link actions with a specific customer, you need to send a login event after the user logs in.

  • Without a login event, data is collected anonymously and an anonymous account is created for the browser session.
  • ⚠️ Call the login action only once.
<script type="text/javascript">
  window.addEventListener('load', function () {
    window.ccce = window.ccce || [];
    window.ccce.push({
      trigger: 'login',
      data: {
        contact_type: "customer_id",
        contact_value: `${CUSTOMER_ID}`
      }
    })
  });
</script>

Supported contact_type values

  • customer_id → customer identifier from the CareCloud CRM & CDP system. Example: 8f9de85354bdb777ae1482019b
  • email → customer’s email address. Example: info@carecloud.cz
  • phone → customer’s phone number. Example: 420123456789
  • external_id → object in the format:

    {
    "customer_source_id": "contact-source-id",
    "external_id": "unique-id"
    }

3. Security and Privacy

The script uses COOKIES

  • Inform users transparently (cookie banner, privacy policy).
  • Never send sensitive data (passwords, tokens).
  • Always use hashed IDs.
  • Follow GDPR and local legislation requirements.

4. Debugging and Monitoring

  • For debugging, you can enable debug mode:

    w[l] = { project_url: u, project_id: i, debug: true };
  • Monitor the content of window.ccce in the browser console.
  • Verify that events are being stored in the CareCloud CRM & CDP.

5. Recommended Deployment Workflow

  1. Development – integrate with debug: true.
  2. Staging – verify functionality in a pre-production environment with a test installation of your CareCloud CRM & CDP.
  3. Production – configure the production project_url and project_id, disable debug.

6. Example Usage of external_id

<script type="text/javascript">
  window.addEventListener('load', function () {
    window.ccce = window.ccce || [];
    window.ccce.push({
      trigger: 'login',
      data: {
        contact_type: "external_id",
        contact_value: {
          customer_source_id: "eshop_system",
          external_id: "usr_123456789"
        }
      }
    })
  });
</script>

7. Developer Section

Testing in Console

During development, you can send events directly from the console:

window.ccce.push({
  trigger: 'login',
  data: {
    contact_type: "email",
    contact_value: "test@example.com"
  }
});