Detect bots on the web
The bot detection plugin uses FingerprintJS BotD to detect automated browsers such as Selenium, PhantomJS, or headless Chrome. It attaches a client_side_bot_detection entity to every event.
This is useful when you want to identify bot traffic as early as possible, before events reach your pipeline. For a broader approach that also incorporates server-side indicators, see the bot detection enrichment.
The plugin is available since version 4.7 of the tracker.
The bot detection entity is automatically tracked once configured.
Install the plugin
- JavaScript (tag)
- Browser (npm)
| Tracker Distribution | Included |
|---|---|
sp.js | ❌ |
sp.lite.js | ❌ |
Download:
| Download from GitHub Releases (Recommended) | Github Releases (plugins.umd.zip) |
| Available on jsDelivr | jsDelivr (latest) |
| Available on unpkg | unpkg (latest) |
The links to the CDNs above point to the current latest version. You should pin to a specific version when integrating this plugin on your website if you are using a third party CDN in production.
window.snowplow('addPlugin',
"https://cdn.jsdelivr.net/npm/@snowplow/browser-plugin-bot-detection@latest/dist/index.umd.min.js",
["snowplowBotDetection", "BotDetectionPlugin"]
);
npm install @snowplow/browser-plugin-bot-detectionyarn add @snowplow/browser-plugin-bot-detectionpnpm add @snowplow/browser-plugin-bot-detection
import { newTracker } from '@snowplow/browser-tracker';
import { BotDetectionPlugin } from '@snowplow/browser-plugin-bot-detection';
newTracker('sp1', '{{collector_url}}', {
appId: 'my-app-id',
plugins: [ BotDetectionPlugin() ],
});
Output
The plugin attaches a client_side_bot_detection entity to every event.
client_side_bot_detection
SchemaExample
{
"bot": true,
"kind": "headless_chrome"
}
Properties and schema
- Table
- JSON schema
| Property | Description |
|---|---|
botboolean | Required. Whether the current browser is identified as a bot |
kindstring | Optional. The type of bot detected. Populated when bot is true, null or omitted otherwise. See https://github.com/fingerprintjs/BotD/blob/main/src/types.ts Must be one of: awesomium, cef, cefsharp, coachjs, electron, fminer, geb, nightmarejs, phantomas, phantomjs, rhino, selenium, sequentum, slimerjs, webdriverio, webdriver, headless_chrome, unknown, |
{
"$schema": "http://iglucentral.com/schemas/com.snowplowanalytics.self-desc/schema/jsonschema/1-0-0#",
"description": "Schema for bot detection entity, powered by the BotD library (https://github.com/fingerprintjs/BotD)",
"self": {
"vendor": "com.snowplowanalytics.snowplow",
"name": "client_side_bot_detection",
"format": "jsonschema",
"version": "1-0-0"
},
"type": "object",
"properties": {
"bot": {
"description": "Whether the current browser is identified as a bot",
"type": "boolean"
},
"kind": {
"description": "The type of bot detected. Populated when bot is true, null or omitted otherwise. See https://github.com/fingerprintjs/BotD/blob/main/src/types.ts",
"type": [
"string",
"null"
],
"enum": [
"awesomium",
"cef",
"cefsharp",
"coachjs",
"electron",
"fminer",
"geb",
"nightmarejs",
"phantomas",
"phantomjs",
"rhino",
"selenium",
"sequentum",
"slimerjs",
"webdriverio",
"webdriver",
"headless_chrome",
"unknown",
null
]
}
},
"required": [
"bot"
],
"additionalProperties": false
}
Bot detection runs asynchronously. Events tracked before detection completes won't have this entity attached. In most cases, detection finishes within milliseconds, but if you need the entity on the very first event, consider deferring your initial tracking calls until the tracker is fully initialized.
The bot detection enrichment can consolidate this client-side indicator with server-side indicators from YAUAA, IAB, and ASN lookups into a single bot_detection entity.