Docs

File DA-008 View as Markdown

Plugins

Every integration is a plugin. So is the Double Agent cloud. You can add your own:

doubleagent.use({
  name: 'mytool',                 // unique; a later plugin with the same name replaces it
  cat: 'analytics',               // consent category: 'analytics' (default) | 'ads' | 'functional'
  setup(ctx) { return () => {} }, // once per session; the teardown runs on reset() and pagehide
  apply(verdict, ctx) {},         // every distinct verdict; ctx.event is 'da_classified' / 'da_final' once per session
  report(payload, ctx) {},        // the session payload: payload.reason is 'ready' | 'change' | 'hidden' | 'pagehide' | 'flush'
});

A new analytics tool

Browser only: nothing leaves the page except through the tool itself.

doubleagent.push('use', {
  name: 'acme',
  apply(v, ctx) {
    if (!ctx.allowed) return;
    window.acme?.setUserProperties({ da_class: ctx.fields.da_class, da_score: ctx.fields.da_score });
    if (ctx.event) window.acme?.track(ctx.event, ctx.fields);
  },
});

Your own backend

The reports also go to your server, next to the Double Agent cloud.

doubleagent.push('use', {
  name: 'mybackend',
  report(p, ctx) {
    ctx.send('https://collect.example.com/da', { reason: p.reason, sid: p.sid, verdict: p.verdict, pages: p.pages });
  },
});

Cloud off, your own backend only

<script>window.doubleagent=window.doubleagent||{q:[],push(){this.q.push(arguments)}};
doubleagent.push('use', { name: 'mybackend', report(p, ctx) { ctx.send('https://collect.example.com/da', p); } });</script>
<script async src="https://cdn.doubleagent.so/v1/doubleagent.js" data-cloud="off"></script>

npm: doubleagent.init({ cloud: false, plugins: [mybackend] }).

With the cloud off, the SDK makes no request to Double Agent. Verdicts, integrations and your plugins keep working. Everything that needs the cloud stops:

See Capabilities.