agentleFS
surendranbsurendranb/google-analytics-mcp/skills/bot-traffic-detection/SKILL.md

bot-traffic-detection

Skill244 starsChanged 43 days agoMITView on GitHub

Identify and exclude bot, scraper, and spam sessions from GA4 data.

Files
SKILL.md

Bot Traffic Detection

Identify and exclude bot, scraper, and spam sessions from GA4 data.

When to use

  • Traffic has unexplained spikes that don't correlate with any activity
  • Bounce rate is 0% or near-100% across many sessions
  • Sessions show 0 engagement time but high pageview counts
  • Referrers look suspicious (random domains, unrecognised TLDs)
  • You want to establish a clean baseline before any analysis

How to detect

Step 1 — Check engagement time distribution

Query sessions with very low or zero engagement:

dimensions: ["sessionDefaultChannelGroup", "sessionSource", "sessionMedium"]
metrics: ["sessions", "userEngagementDuration", "bounceRate", "screenPageViewsPerSession"]
date_range: last 7–14 days

Bot signals: userEngagementDuration near 0, screenPageViewsPerSession exactly 1, bounceRate at 1.0 (100%).

Step 2 — Inspect referrer sources

dimensions: ["sessionSource", "sessionMedium", "sessionDefaultChannelGroup"]
metrics: ["sessions", "userEngagementDuration", "newUsers"]
dimension_filter: sessionMedium = "referral"

Flag sources where userEngagementDuration / sessions < 2 seconds.

Step 3 — Check hostname

dimensions: ["hostname"]
metrics: ["sessions", "screenPageViews"]

Bot traffic often hits unexpected hostnames (staging domains, raw IPs, or hostnames you don't own). Filter to your known production hostnames.

Step 4 — Geographic anomalies

dimensions: ["country", "city", "sessionSource"]
metrics: ["sessions", "userEngagementDuration"]
dimension_filter: country = [countries with no expected traffic]

Clusters of sessions from unexpected countries with 0 engagement = bot signal.

Exclusion approach

GA4 does not have a native bot filter toggle beyond the automatic Google filter. To exclude suspected bot traffic from your analysis, add a dimension filter:

dimension_filter: {
  "filter": {
    "fieldName": "sessionDefaultChannelGroup",
    "stringFilter": {"matchType": "EXACT", "value": "Direct"}
  }
}

…combined with a metric filter on userEngagementDuration > 0.

Note: GA4 already filters known bots automatically. What remains are unknown/new bots and scrapers that mimic real browser behaviour.

What to report

  • Total suspicious sessions as % of all sessions
  • Top suspicious sources with their engagement metrics
  • Whether the pattern is new (spike) or chronic (baseline contamination)

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.