LogDuck Documentation

Site analytics

Markdown: this page · all of the docs · index

The Site tab counts how people move through your website: page views, time on page, 404s and site searches, by page, referrer, country, device and browser. It is separate from events: a page view never triggers a notification or a webhook, and it counts against its own monthly allowance, not your event limit.

Anonymous by design. Nothing is stored on the visitor's device: no cookie, no local storage, no persistent fingerprint, so no consent banner is needed for it. The server keeps a country and a city from the address and a device class and browser family from the user agent, and discards both. Page views are joined into sessions on the server with a key that changes every day and is never stored with the address, so nothing follows a visitor from one day to the next. Query strings are read for UTM parameters and dropped; external referrers keep only their host.

Setup

Create a client key for the site on the API keys page, with the site's origins listed — the key ships in the page, and the origin list is what stops another site spending your allowance. Then add one tag, or the npm entry point:

<script async src="https://cdn.jsdelivr.net/npm/logduck@2/dist/usage.global.js" data-key="ld_..."></script>

Page views are recorded on load and on every history change, and a page leave with time on page and scroll depth when the tab is hidden. Hits are batched and sent with a beacon, so nothing is lost on navigation. Without a document (server rendering) every call is a no-op.

What you see

Page views over the range with time on page, scroll depth and 404s; top pages, referrers (with UTM source, medium and campaign), countries, devices and browsers, searches and dimensions. Today's figures update every minute; the rest refreshes about every fifteen minutes. Crawlers are counted separately and excluded unless you include them.

Dimensions describe a page — dealer, section, author, experiment variant — as up to ten lowercase keys with short string values, attached to every hit. They must never be identifiers: keys named like one (email, user_id, ip) are refused.

Apps

The Swift and Kotlin SDKs record screen views and the app lifecycle into the same Site tab: a screen view counts as a page view, with the screen name where a page has its path and the previous screen as its referrer; app opens, installs and foreground time are stored for the retention reports to come. App hits show as the mobile device class and the app browser family.

The key. An app sends no origin, so its client key needs allow requests without an origin switched on. Such a key gets its own rate limit and may spend at most a quarter of the organization's monthly allowance, because a key inside an app binary can be extracted; past that share its hits are dropped and counted until the month resets.

import LogDucklet usage = LogDuckUsage(key: "ld_...")   // a client key with missing origins allowedusage.screen("Checkout")          // a screen.view; the previous screen is rememberedusage.consent(true)               // consent basis: mints an install IDusage.identify("user-42")        // signed-in users, no consent needed

Sessions and identity. An app knows its own session: the SDK sends a session ID that is renewed after thirty minutes in the background, and the server uses it instead of the daily key it derives for websites. consent(true) mints an install ID kept on the device and sent with later hits; identify(userId) attaches your own user ID without it. Both are stored only once identity collection is on for the organization. Hits are batched, kept on the device while offline, and sent in one request when the app goes to the background.

Identity

Off by default. Until an owner or admin switches identity collection on under the organization's Settings, the server strips every visitor, install and user ID from every hit, whatever your code sends, and counts the stripped hits on the Site tab. Switching it on requires the current Terms of Service with the Data Processing Agreement accepted, and you declare the lawful basis you rely on: consent, contract, legitimate interest, or public task (a public authority cannot pick legitimate interest). LogDuck records your choice and never names a basis for you. A change reaches collection within a minute.

Two ways to identify. consent(true) is for the consent basis: call it after the visitor has agreed in your own banner. It mints a random visitor ID, keeps it in local storage or in a first-party cookie when you pass cookieDomain, and attaches it to every later hit; consent(false) deletes it. identify(userId) attaches your own user ID from an authenticated session and needs no visitor ID or consent call, because nothing is stored on the device; it is what the contract, legitimate-interest and public-task bases use.

const usage = createUsage({ key: 'ld_...', cookieDomain: '.example.com' });// After the visitor agrees in your banner:usage.consent(true);// If they withdraw:usage.consent(false);
const usage = createUsage({ key: 'ld_...' });// From an authenticated session, under contract, legitimate interest or public task:usage.identify(currentUser.id);// On sign-out:usage.identify('');

Global Privacy Control. A browser that sends the signal keeps its device identifiers out whatever the basis: the SDK ignores consent(true) and the server withholds the visitor and install IDs. The user ID from identify is kept under contract and public task, and withheld under consent and legitimate interest, where the signal counts as withdrawing or objecting. Withheld identifiers are counted on the Site tab, never dropped silently.

Allowance

The free plan includes one million hits a calendar month across the organization, subject to change with notice. Crawler hits never count. Past the allowance, hits are dropped until the month ends and the Site tab says so; everything that arrived and was not counted — anonymised, malformed, over the allowance, refused for its origin — is listed on the allowance card rather than dropped silently.

Settings

Per environment, owners and admins can turn on storing search terms (capped at 100 characters, runs of six or more digits masked) and set the largest client-side sample rate the SDK may use. Both are off by default. With sampling, the SDK sends one hit in N and the dashboard weights the numbers back up. They also choose how long page views are kept: 35 days for anonymous ones and 13 months for identified ones by default, 13 months at most; keeping anonymous ones longer than 35 days needs Pro. Older rows are deleted nightly, and the charts keep their history.