captureCDR()
Capture a snapshot of the page, upload it, and get back a cdrId confirming the evidence is persisted.
Usage
const result = await window.ExpressConsent.captureCDR({
custom: { phoneNumber: "+15551234567", formName: "lead-form" },
highlightTarget: "consent-submit",
subGroupIds: ["step-1"],
autoShare: true,
});
// Store cdrId with your lead/user record.
console.log(result.cdrId);
// If autoShare is enabled, pass the share URL to your lead buyer.
console.log(result.shareUrl);If page navigation happens before the promise resolves, the CDR may not be saved. Always preventDefault() → await → submit/navigate.
Inputs
custom
Arbitrary metadata stored with the CDR. Use it to make evidence searchable later (lead IDs, phone numbers, campaign IDs, etc). Must be JSON-serializable. Max 16 KB.
highlightTarget
A string token that highlights a specific element in the visual record. It must match a data-expressconsent-highlight-label attribute in the page. See Highlighting & Masking.
subGroupIds
Optional array of string identifiers for multi-step / co-registration flows. Creates additional Packages for grouping CDRs. Max 5 unique values. See Sessions & Packages.
autoShare
Auto-generate a share token so you can pass consent evidence to a lead buyer without a separate API call. Pass true for defaults (30-day expiry) or an options object:
autoShare: true— 30-day expiry (default)autoShare: { expiresInMs: 604800000 }— custom expiry (max 2 years)
When enabled, the result includes shareUrl, shareToken, and shareExpiresAt. See Sharing with Lead Buyers.
timeoutMs
Optional request timeout in milliseconds. Overrides the SDK’s default adaptive timeout budget.
Return value
Always present:
cdrId— the evidence ID. Store this with your lead/user record.packageData— session grouping identifiers. ContainspackageId(the session-level package) andsubGroupIdMap. Only relevant if you’re building package-aware workflows.
Present when autoShare is enabled:
shareUrl— full absolute URL the lead buyer POSTs to with their API key to claim the evidence.shareToken— the raw share token (the last segment of the URL).shareExpiresAt— token expiry as a Unix timestamp in milliseconds.
Error behavior
captureCDR() throws when it cannot guarantee persistence:
- SDK not loaded (missing script tag or
data-ec-cid) - Network failure or timeout
- Upload endpoint unreachable (e.g. from self-hosting the SDK)
Wrap the call in a try/catch and decide your policy: most teams log the error and let the form submit proceed, but some workflows may require blocking submission on failure.
Automatic signals
The SDK automatically captures the user’s IP address and User-Agent from the upload request. These appear in the CDR as signer telemetry — no code changes needed.