File DA-035 View as Markdown

Segment

With Segment's Analytics.js on your site, every event carries the da_* fields under context.doubleagent, and each user gets them as traits. Your warehouse and destinations can then tell humans from bots and agents. Nothing to add in code.

What Segment gets

// added once by the script
analytics.addSourceMiddleware(({ payload, next }) => {
  payload.obj.context.doubleagent = { da_class, da_agent, da_score, da_bucket, da_rec, da_verified, da_behavior, da_behavior_risk, da_authorization };
  next(payload);
});
analytics.identify({ /* the same fields */ });   // when the verdict changes

The middleware reads the latest verdict at the moment each event is sent. Needs analytics consent. Field values: Verdict.

Use it

  • Keep bots out of a destination: in the destination's Filters, drop events where context.doubleagent.da_class

equals bot. Destination filters need Segment's Business tier.

  • In your warehouse: the fields land in the context_doubleagent_* columns of your event tables, and as traits on

identifies. Query on context_doubleagent_da_class.

Check it worked

Open your source's Debugger in Segment and load your site. Open any event: context.doubleagent.da_class should be there.

Next: PostHog or How integrations work.