File DA-029 View as Markdown
GA4
With GA4 on your site, every visitor gets a da_class user property (human, bot or agent), so you can split any report by it or drop confident bots from your data. Nothing to add in code: the script finds gtag() and sends the fields.
What GA4 gets
gtag('set', 'user_properties', { da_class, da_agent, da_score, da_bucket, da_verified, da_behavior, da_behavior_risk, da_authorization });
gtag('event', 'da_classified', { da_class, da_agent, da_score, da_bucket, da_rec, da_verified, da_behavior, da_behavior_risk, da_authorization });
The user properties are set on every new verdict. The da_classified event goes once per session. It is not a key event, so it does not make a session engaged. Field values: Verdict.
Show the fields in reports
- In GA4, open Admin › Data display › Custom definitions and choose Create custom dimension.
- Name it
Double Agent class, set the scope to User and the user property toda_class. Save. - Do the same for
da_agent(which agent) and, if you want them,da_behaviorandda_verified.
New dimensions start showing data 24 to 48 hours after you create them. Older data is not backfilled. A standard GA4 property has room for 25 user-scoped custom dimensions, so register only the fields you will use.
Drop confident bots from GA4
Turn on trafficType and the script also sets traffic_type to bot when the class is bot with a bot probability of 0.9 or more:
doubleagent.push('init', { integrations: { ga4: { trafficType: true } } });
Listing integrations this way runs only the tools you list. Add the others you use, for example { ga4: { trafficType: true }, meta: true }. See How integrations work.
Then filter it in GA4:
- Open Admin › Data collection and modification › Data filters, choose Create filter and pick Internal traffic.
- Set the operation to Exclude and the parameter value to
bot. GA4 matches it againsttraffic_type, the only parameter a data filter reads. - Leave it in Testing for a few days. Testing marks the matching traffic without removing it, so you can compare with the
Test data filter namedimension. - Switch it to Active. From then on GA4 drops those hits for good, so be sure first.
Check it worked
Open your site in a normal browser, then in GA4 go to Reports › Realtime. Under Event count by Event name you should see da_classified. User properties take up to a day to show in standard reports.
Fix labels after the page
When the server settles a different label for a session, it sends a da_final event through the Measurement Protocol, joined on the visitor's GA client id. It sends one only when the class, behaviour label or authorization decision differs from what GA4 last got (the first time, from what the browser already sent), not on every check. Add your Measurement ID and an API secret in Sites › your site › Settings › Server relabel credentials. See Relabel.
Next: Google Tag Manager if you send GA4 through GTM, or Meta, TikTok and Google Ads to keep bots out of ad conversions.