# KarrotAnalytics Web SDK: when 64% of browser IDs are bots

Karrot's data team extended its app logging system to the web and built a web logging SDK. Over two weeks, 13.6% of web events and 64% of browser IDs came from bots. The team flags bots with an is\_bot column instead of dropping them. A read for small sites.

- Language: en
- Published: 2026-12-01
- Tags: dev, daangn, web, analytics, sdk, logging, bot, session, frontend
- URL: https://devs7ud.io/en/deep-dives/daangn-karrotanalytics-web-sdk-web-behavior-log-bot-session-en
- Translation (ko): https://devs7ud.io/deep-dives/daangn-karrotanalytics-web-sdk-web-behavior-log-bot-session.md

## Behind an SDK used in two calls

Mika, a frontend engineer on Karrot's data team, published an engineering post on the Karrot tech blog on November 30, 2026. It covers how the team extended its app logging system for user behavior to the web, and the web logging SDK it built along the way, KarrotAnalytics Web SDK. Karrot is the Korean neighborhood marketplace known at home as Daangn. The post came out in Korean and English on the same day.

| 항목 | 값 | 설명 |
| --- | --- | --- |
| Web events from bots | 13.6% | Of web events collected over two weeks |
| Browser IDs that were bots | 64% | Classified as bots in the same two weeks |
| Session timeout | 30min | Of inactivity since the last action |

_Source: Karrot tech blog. Both ratios were measured on Karrot's own web products over two weeks._

The code on the product side is short. A service initializes the SDK once, and default logs such as page views start to collect. Product-specific actions are added with `track()`. The source says that is all there is to using it.

```ts
karrotAnalytics.init({ serviceName: "service name", countryCode: "country" });

karrotAnalytics.track("event name", {
  [parameter name]: [parameter value]
});
```

_Code: [Karrot tech blog](https://medium.com/daangn/collecting-web-behavior-logs-at-karrot-building-the-karrotanalytics-web-sdk-16b483ca404b)_

This post reads what the SDK handles behind those two calls, in five parts: the policy the team set first, identifiers and sessions, bots, sending logs as a page goes away, and the guards that keep the host service running. KarrotAnalytics is an internal system at Karrot, and the source does not say whether the SDK will be released outside the company. So this is not a tool to install. It is a record of what has to be decided before collecting web logs.

## App logs and web logs in separate places

Karrot was an app-first service for a long time. According to the source, its web products have grown fast, and real estate, part-time jobs, used cars, Neighborhood Life and Groups can now be used from a desktop browser.

The team was already collecting user behavior logs on the web. It used a third-party service to store and analyze events, and that was enough while there were only a few web products and each team looked at its own data. The trouble came when app and web had to be read together. App and server logs sat in the internal system, KarrotAnalytics. Web logs sat in the third-party service. The identity scheme, the event naming rules and the tools all differed, so joining the two sets of data was a separate job every time.

The team decided to support web logs in KarrotAnalytics. The source lists four gains.

- **One place:** App and web logs land in the same place. For a logged-in user, app and web behavior can be read as one sequence.
- **Internal tools:** Teams can define events in Event Center, run experiments on the experimentation platform and ask an agent about the data.
- **Same method:** Web logs are instrumented the same way as app logs. The naming rules are the same, so there is nothing new to learn.
- **Every event:** The team owns the data, so it collects every event and does not sample to save cost.

## Four decisions made before the code

The team wrote down its policy before writing the SDK, because web events and app events behave very differently.

| What the web is like | What the team decided |
| --- | --- |
| Most visitors are not logged in | Tell browsers apart, not people |
| Non-human visitors are mixed in | Make it possible to filter out bots |
| There is no clear moment of opening or closing | A visit ends after 30 minutes with no action since the last one |
| An action alone cannot be analyzed | Define the common fields every event must carry |

_Source: the Karrot tech blog post, arranged as a table._

The app requires login, so behavior logs can be grouped by user. On the web, most people arrive from a search, look around and leave. The meaning of one visit differs too. An app has a clear moment of opening and closing. On the web, people keep several tabs open or simply walk away. The source says that visit counts, time on site and bounce rate stay stable only once the team has defined where one visit ends.

Non-human visitors come in four kinds: search engine crawlers that index pages for search results, AI search bots that gather material for answers, headless browsers where a program opens Chrome with no screen, and ad and SEO tool bots that check pages carrying ads or factors behind search ranking.

![The source's diagram of web visitors: people in a browser and four kinds of bots all leave the same logs, and only humans pass to analysis after bots are filtered out](/blog-img/daangn-karrotanalytics-web-sdk-web-behavior-log-bot-session/1-en.png "Kinds of web visitors")

_Image: [Karrot tech blog](https://medium.com/daangn/collecting-web-behavior-logs-at-karrot-building-the-karrotanalytics-web-sdk-16b483ca404b)_

![The source's diagram of a session: three actions on a timeline form one session, and after 30 minutes with no activity the next action starts a new session](/blog-img/daangn-karrotanalytics-web-sdk-web-behavior-log-bot-session/2-en.png "Session definition")

_Image: [Karrot tech blog](https://medium.com/daangn/collecting-web-behavior-logs-at-karrot-building-the-karrotanalytics-web-sdk-16b483ca404b)_

The fourth decision is the common fields. An event has to say what the action was and also in what context it happened. So the team first fixed the information that must be present for web analysis to mean anything. The SDK is these four decisions turned into code.

## Visits split without a timer

To tell anonymous visitors apart, the SDK gives each browser an identifier, `web_device_id`. On a first visit it generates a UUID and stores it. On later visits it reads the stored value.

Where local storage is not available, as in private browsing, the identifier lives in memory only. A reload issues a new one, and the SDK does not count that as a first visit. This keeps the metric from being inflated. When a user logs in, the host service calls `identify()`, and every event after that carries the user ID. Calling `reset()` clears it.

A session is one record in `localStorage` holding `sessionId`, `lastActivityAt` and `startedAt`. Expiry is not decided by a timer. It is decided by a comparison at the moment the record is read.

```ts
const SESSION_TIMEOUT_MS = 30 * 60 * 1000;

function isExpired(session: StoredSession, at: number): boolean {
  return at - session.lastActivityAt > SESSION_TIMEOUT_MS;
}
```

_Code: [Karrot tech blog](https://medium.com/daangn/collecting-web-behavior-logs-at-karrot-building-the-karrotanalytics-web-sdk-16b483ca404b)_

The source gives two reasons for not ending a session with `setTimeout` after 30 minutes.

- When a tab goes to the background, the browser slows or stops its timers.
- In an MPA, where every page is a fresh load, the timer disappears with the memory the moment the user moves to another page.

Instead, the SDK updates `lastActivityAt` on every event. If 30 minutes have passed, it creates a new session and records `web_session_start`. Tabs on the same domain share `localStorage`, so a visit that moves across tabs stays in one session.

There is also a guard for storage that fails. The SDK keeps a memory cache next to storage and uses whichever of the two has the more recent `lastActivityAt`. Where only writes fail, a stale stored value could otherwise hide the cache and create a new session on every event.

## Bots flagged, not dropped

The numbers the team measured are the most striking part of the post. Over two weeks, 13.6% of web events came from bots. In the same period, 64% of browser IDs were classified as bots.

The gap between the two ratios comes from how identifiers are issued. A bot starts each visit with a new browser whose storage is empty. With no stored identifier, every visit counts as a new visitor. In the source's words, bots inflate the number of new visitors far beyond their share of events.

There are two ways to handle bots: drop them at collection, or accept everything and mark it as bot traffic. Karrot chose to mark, for two reasons.

- The detection rules keep changing. When a new bot appears the rules have to be fixed, and data that was dropped cannot be read again.
- Records of people who were wrongly classified remain, so they can be checked later.

So every web event has an `is_bot` column, and analysis filters with `is_bot IS NOT TRUE`. A `NULL` value means there was no information to decide on.

Two signals feed the decision. One is the User-Agent. Search engine crawlers and AI search bots state their own name there. The other is `navigator.webdriver`, a flag that a browser under an automation tool turns on by web standard. It is the only such value the SDK puts in an event.

The decision is made on the collection server, not in the browser, because anything a browser reports about itself can be faked.

**Where bots are detected**

- Web SDK → Event collection server
- Event collection server → Cleansing
- Cleansing → Analysis

_Source: Karrot tech blog. The cleansing stage runs on Flink._

The cleansing stage classifies browser, operating system and device type with a User-Agent parser. It then marks the event as a bot if any one of the three conditions below holds. If the event body arrives with an `is_bot` value, that value is removed and only the server's verdict is kept.

- The parser classifies the device as a robot
- The User-Agent contains `HeadlessChrome`
- `webdriver` is `true`

For the same reason, browser, operating system, device type and country are not filled in by the SDK. The server works them out from the request.

## Logs that arrive after the tab closes

An app stays alive in the background. On the web, everything is gone the moment a tab closes. Several parts of the transport exist for that reason.

Events are not sent as they happen. They collect in a buffer. Every 3 seconds, or once 30 events have piled up, the buffer is emptied, and the batch is split into chunks of 100 events or 64 kB to form requests. This is also why each event carries both the time it happened (`event_ts`) and the time it was sent (`sent_ts`). The difference between the two is the time spent waiting in the buffer.

![The source's diagram of the transport: events from track collect in a buffer and are split into chunks, then go to the collection server by gzipped fetch in normal use and by sendBeacon when the page is leaving. Below are the response classes and retry delays growing from 3 to 6, 12, 24 and 30 seconds](/blog-img/daangn-karrotanalytics-web-sdk-web-behavior-log-bot-session/3-en.png "zoom")

_Image: [Karrot tech blog](https://medium.com/daangn/collecting-web-behavior-logs-at-karrot-building-the-karrotanalytics-web-sdk-16b483ca404b)_

The `keepalive` option of `fetch` lets a request continue after the page is gone. According to the source, though, browsers cap the total of `keepalive` requests per page at 64 kB. A large batch sent with `keepalive` goes over the cap and fails silently. So the SDK sets `keepalive` only on requests of 16 kB or less and sends larger ones as a plain `fetch`.

When the page is really closing, the SDK uses `navigator.sendBeacon` instead of `fetch`. There is no response to read, but the browser takes responsibility for delivery after the document is unloaded.

The SDK also separates looking at another tab for a moment from leaving for good.

| Browser event | What the SDK does |
| --- | --- |
| visibilitychange \(hidden\) | Flushes the remaining events only |
| pagehide | Records web\_page\_leave and flushes the remaining events |
| pageshow \(persisted\) | Records web\_page\_view again and keeps tracking |

_Source: Karrot tech blog. persisted means the page was restored from bfcache by going back._

If `web_page_leave` fired whenever a tab was hidden, every tab switch would be recorded as leaving, and time on page would be wrong. So the leave record is written on `pagehide` only.

## Three rules that keep the service running

A logging SDK runs inside the host service, so a problem in the SDK is a problem in the service. The source says taking the service down is a much bigger incident than losing logs, and sets three invariants.

- **Errors never escape.** Exceptions are swallowed and recorded, and reach the console only when `debug: true`.
- **Nothing breaks under SSR.** Browser APIs are never touched at module top level, and browser features are used only behind an `isBrowser()` guard. On the server `globalThis` is shared between requests, so the singleton registry returns a fresh instance each time.
- **`shutdown()` restores everything.** When the host takes the SDK down, it sends the remaining events and then puts back listeners, timers, global patches and stored values.

Retries have a ceiling too. A send result falls into one of three classes by HTTP status code.

| Response | Handling |
| --- | --- |
| 2xx | Success |
| 429 | Retry. If there is a Retry-After header, follow it |
| 408 and 5xx | Retry |
| 400, 403 and the rest | Drop. Sending again would give the same result |

_Source: the classifyResponse code in the Karrot tech blog post, arranged as a table._

The retry delay starts at 3 seconds, doubles each time and never exceeds 30 seconds. Even if the server keeps returning 5xx, the SDK asks only once every 30 seconds, and the source describes this cap as acting as a circuit breaker in effect. Failed events go back to the front of the buffer to keep their order, and an event that has been attempted more than 10 times is dropped.

Default logs collect without any instrumentation. There are four: `web_first_visit`, `web_session_start`, `web_page_view` and `web_page_leave`. What the source says took the most care in auto-capture is recording `web_page_view` exactly once per page in every environment.

| Environment | When a page view is recorded |
| --- | --- |
| MPA | Once, when the page loads |
| SPA | history.pushState and replaceState are wrapped, and back and forward are detected with popstate. Consecutive calls are… |
| SSR | Nothing on the server. Once at init, after hydration finishes |
| bfcache restore | There is no load event, so it is recorded again on pageshow |

_Source: Karrot tech blog._

## Reading visit counts on a small site

A site does not need Karrot's scale to take something from this post. A person running one blog or one landing page also looks at visits and new visitors. The post contains a standard for reading those numbers.

| The source's choice | Moved to our own site |
| --- | --- |
| Measured and confirmed that bots inflate new visitor counts | Check first whether the new visitor count is the value after bots are filtered |
| Keeps bot records and marks them with an is\_bot column | If you store logs yourself, mark with one column and do not filter and delete |
| Decides session expiry by comparing the last action time, not by a timer | If you split sessions yourself, store the last action time and compare on read |
| Sends the leave record on pagehide with sendBeacon | If you measure exits and time on page, do not record leaving on visibilitychange |
| Detects bots on the server from the request header | Do not decide who is human from values the client sends alone |

_The left column is from the Karrot tech blog. The right column is this post's own summary and is not in the source._

A site that uses an external analytics tool has nothing to build here. What it can do is check, in the tool's settings and documentation, how the tool treats bot traffic and after how many minutes it ends a session. Then the numbers can be read against the same standard.

The end of the source covers developer tooling. Because the SDK batches events every 3 seconds and sends them gzipped, the request bodies are hard to read in the browser's Network panel, so the team built an internal Chrome extension that shows events inside Chrome DevTools. The source also says most events are now registered through MCP, and that the logging conventions are packaged as a skill, so naming an event and checking for duplicates both finish inside the AI tool.

## View

The center of this post is the order of work, not the SDK code. The team first wrote down what identifies a visitor, how bots are treated, where one visit ends and what every event carries. Numbers in the code such as 30 minutes, 16 kB and 10 attempts all follow from that policy. Because the policy came first, each number has a reason attached.

The same order works in design. It resembles the way a design system fixes tokens and rules before any screen is drawn. In logging, those rules are event names and common fields.

For anyone running a blog or a community, this changes how a visit count is read. If 64% of identifiers were bots, a graph of rising new visitors cannot be taken at face value. That figure was measured on Karrot's web products over two weeks, though. It comes from a service with heavy search traffic and many pages, so it does not carry over to other sites. The ratio for a given site has to be measured on that site.

Some things cannot be known from the source. It does not give the share of people wrongly classified as bots, or how many bots get past detection. The source itself names two remaining tasks: making sure logs arrive from pages that live only for a very short time, and telling newly appearing bots apart better.

## Source

- [Collecting Web Behavior Logs at Karrot: Building the KarrotAnalytics Web SDK](https://medium.com/daangn/collecting-web-behavior-logs-at-karrot-building-the-karrotanalytics-web-sdk-16b483ca404b) — Mika, November 30, 2026
- [당근의 웹 사용자 행동 로그 수집: KarrotAnalytics Web SDK 개발기](https://medium.com/daangn/%EB%8B%B9%EA%B7%BC%EC%9D%98-%EC%9B%B9-%EC%82%AC%EC%9A%A9%EC%9E%90-%ED%96%89%EB%8F%99-%EB%A1%9C%EA%B7%B8-%EC%88%98%EC%A7%91-karrotanalytics-web-sdk-%EA%B0%9C%EB%B0%9C%EA%B8%B0-6cac42009e9a) — The Korean original, November 30, 2026
