Custom permission interface
Use your existing consent system as the authority. Dark Traffic supplies an interface, not a banner. Your integration must translate saved choices and later changes into the appropriate purposes under your website’s policy. Do not treat provider detection, banner dismissal or page visibility as permission.
Queue the saved state
Section titled “Queue the saved state”The same push interface works before and after the script loads. Use the public site ID from the installation snippet and send only these fields. Install the SDK for one site per document.
window.darkTraffic = window.darkTraffic || [];window.darkTraffic.push({ type: 'permission', site: 'YOUR_PUBLIC_SITE_ID', measurement: 'allowed', recognition: 'denied',});Run this from your approved website script or nonce-authorized integration; do not loosen CSP to paste inline code. Supply the applicable saved state before loading the SDK when possible. Replaying a saved grant needs no new visitor click. Commands are processed in order, and a queued withdrawal clears the old credential before a later grant. Do not replace window.darkTraffic after the SDK takes ownership.
Each purpose accepts unknown, pending, allowed, denied or withdrawn. Omit a purpose to leave it unchanged. unknown and pending follow default mode, while permission-waiting mode requires allowed. Explicit denial/withdrawal remains in force until an explicit new allowed state; an uncertain update does not erase it. Browser opt-outs and current backend controls still win. An invalid command pauses collection until a valid site-scoped update is supplied; a command for another site is ignored. The initial queue is bounded to 100 commands.
Apply later changes
Section titled “Apply later changes”Allow recognition separately after measurement has been allowed:
window.darkTraffic.push({ type: 'permission', site: 'YOUR_PUBLIC_SITE_ID', recognition: 'allowed',});An applicable grant on an active anonymous visit does not add a foreground opening. A new identifier is independent of a retired or expired one. When the visitor withdraws all measurement:
window.darkTraffic.push({ type: 'permission', site: 'YOUR_PUBLIC_SITE_ID', measurement: 'withdrawn',});This stops local measurement immediately, clears the known recognition cookie and attempts a narrow retirement control using only site/hostname and the affected opaque credential. It sends no denied page address or title. If offline or blocked, diagnostics report retirementPending; do not claim that the server acknowledged an unsent control. Recognition-only withdrawal can leave permitted anonymous measurement running on later qualifying activity. Temporary state never restores a retired identity, and no persistent fallback is used.
window.darkTraffic.diagnostics() is read-only and sends no analytics request. It reports this browser’s local integration state, not a legal consent record or proof that every visitor has granted permission. Native Cookiebot, CookieYes, OneTrust and Complianz adapters remain Planned; an independently implemented integration can use this custom interface now.