Filter Bot Events

Filter Bot Events

Filters out events from known bot user agents. This transformation will drop the event if a bot is detected.

Configuration

OptionDescription
User Agent Property
Type: string
Required: True

The property that contains the user agent string (e.g. $raw_user_agent, $useragent)

Filter out known bot user agents
Type: boolean
Required: True

Filter out known bot user agents using PostHog's known bot user agents list. This is kept up to date dynamically.

Custom Bot Patterns
Type: string
Required: False

Additional bot patterns to detect, separated by commas (e.g. mybot,customcrawler)

Filter out known bot ips
Type: boolean
Required: True

Filter out known bot ips using PostHog's known bot ips list. This is kept up to date dynamically.

Custom IP Prefixes
Type: string
Required: False

Additional IPv4 or IPv6 prefixes in CIDR notation to block, separated by commas (e.g. 198.51.100.14/24,2001:db8::/48)

Keep events where the useragent is not set?
Type: choice
Required: False

Some events such as server-side events may not have a useragent property, choose if you want to keep these events

Using our REST API you can create this transformation like so:

Terminal
# Create a new destination
curl --location 'https://us.i.posthog.com/api/environments/:project_id/hog_functions' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <POSTHOG_PERSONAL_API_KEY>' \
--data '{
"type": "transformation",
"name": "Filter Bot Events",
"inputs": {
"userAgent": {
"value": ""
},
"filterKnownBotUserAgents": {
"value": ""
},
"filterKnownBotIps": {
"value": ""
}
},
"enabled": true,
"template_id": "template-bot-detection"
}'

Community questions

Questions about this page? or post a community question.