RTN Docs

Web SDK · v0.6.0

Consent

Connect RTN to your consent manager, manage purpose-level decisions, and pause collection without losing identity.

Initial state

The SDK resolves the starting decision in this order:

  1. The consent option passed to rtn.init (your consent manager wins and the value is stored).
  2. The visitor's previous decision on this site, stored as rtn_consent.
  3. granted when neither exists.

If a consent manager must decide first, initialize with consent: 'pending':

rtn.init('WRITE_KEY', { consent: 'pending' });

While consent is pending, nothing is sent and no cookie or localStorage entry is written. Events wait in memory.

Record the visitor's decision

// Call after the visitor accepts analytics cookies.
rtn.setConsent('granted');

// Call after refusal or withdrawal.
rtn.setConsent('denied');
  • granted releases buffered events with their original timestamps.
  • denied deletes the anonymous ID, user ID, attribution data, and the queues of every open tab. Other tabs stop immediately.
  • pending resets the decision while your consent manager asks again.

The decision is shared across tabs and reused on later page loads. Call rtn.setConsent(...) from your consent banner's callback; do not infer consent from a page view or button impression.

setConsent(state) is a shortcut for the analytics purpose, which gates all collection. SDK 0.5.0 and later also store separate decisions for other purposes and attaches a snapshot to every event:

PurposeUse
analyticsMain gate for event collection
personalizationOn-site personalization
advertisingAd measurement
audiencesAudience and ad activation
replaySession replay
rtn.setConsentPurpose('advertising', 'granted');
rtn.setConsentPurpose('personalization', 'denied');

rtn.getConsentPurpose('advertising'); // 'granted'

Purposes other than analytics default to pending. Each event carries the snapshot taken when it was created:

"consent": {
  "analytics": "granted",
  "personalization": "denied",
  "advertising": "granted",
  "audiences": "pending",
  "replay": "pending"
}

The snapshot is not a legal consent record on its own. Services that activate data for a purpose must check that purpose and your server-side consent evidence.

Pause instead of revoking

Use pause() for a temporary operational stop, for example during an internal QA session. It keeps identities and already queued events. Calls made while paused are dropped.

rtn.pause();
// ...
rtn.resume();

Use setConsent('denied') only when the visitor withdraws consent.

On this page