Capture your first CDR

Four steps: add the script, tag your form, capture on submit, confirm the evidence landed.

You need two things before you start:

  • Your CID, from Organization → Settings in the dashboard, listed as "Organization ID (CID)".
  • A page with a consent form you can submit.

1. Add the script

Put this in the head of every page that has a consent form. Replace YOUR_CID with your CID.

html
<script
  src="https://sdk.expressconsent.com/sdk/v1/sdk.js"
  data-ec-cid="YOUR_CID"
  async
></script>

async is right here. The script is not needed until someone submits a form, so there is no reason for it to block your page from rendering.

2. Tag your form

Add three attributes so we can read what the person was agreeing to and how they agreed.

html
<p data-ec-disclosure="tcpa">
  By submitting this form, you agree to be contacted at the number provided,
  including by automated technology.
</p>

<input type="checkbox" data-ec-consent-checkbox data-ec-consent-for="tcpa" />

<button type="submit" data-ec-submit>Submit</button>

What each one does:

  • data-ec-disclosure marks the consent language. Its text is captured onto the record, which is what lets a buyer confirm the disclosure named their company.
  • data-ec-consent-checkbox marks the consent checkbox. We record whether it was checked at the moment of submission.
  • data-ec-consent-for binds the checkbox to a disclosure by name. You can leave it off when the page has exactly one disclosure and one checkbox, but naming them is worth the two seconds.
  • data-ec-submit marks the submit control. The one the person presses gets outlined in the visual record. Tag every control that can submit the form. Once any control on the page carries this attribute, a press on an untagged control is not counted as a submission at all.

If your form has no consent checkbox, because the disclosure sits above the button and submitting is the agreement, leave the checkbox out. We record that consent was expressed by submission rather than by a checkbox, which is a different fact.

3. Capture on submit

Call captureCDR() from your submit handler, or wherever submits are first processed on your frontend, and wait for it before letting the form go.

javascript
form.addEventListener("submit", async (event) => {
  event.preventDefault();

  // Read anything you need off the form before the first await.
  const phone = form.phone.value;

  try {
    // captureCDR() must be the first thing you await.
    const { cdrId } = await window.ExpressConsent.captureCDR({
      custom: { phone },
    });

    // Store cdrId alongside the lead. It is how you find this record later.
    await saveLead({ phone, cdrId });
  } catch (error) {
    // Log it and let the submission through. Never block a consumer from
    // submitting because evidence capture failed.
    console.error("ExpressConsent capture failed", error);
  }

  form.submit();
});

Two things in that snippet are load-bearing.

captureCDR() is the first await. The capture reads the page at the moment you call it, so anything you await first ends up in the evidence: a cleared form, a spinner where the button was, a step that has already unmounted. Reading values off the form synchronously beforehand is fine; that is not an await.

Fields you pass in custom become searchable. Include what you would use to find this record later: the phone number, the email, a campaign ID, your own lead ID. Matching is exact but case-insensitive.

custom is one of several options. captureCDR() documents all of them, along with everything the call returns.

4. Confirm it worked

Submit the form yourself, as a consumer would. Then open Domains → your domain → CDRs in the dashboard.

You should see a new record. The cdrId typically comes back in under a second; the visual record renders separately and takes a few seconds more, so give it about ten seconds and refresh.

Open it and check three things:

  1. The image shows your form, filled in with the values you typed.
  2. Your disclosure text is visible in the image.
  3. The submit button you pressed is outlined.

If all three are true, you have a working integration.

Next