Autocapture in Browser SDK 2
이 페이지는 아직 귀하의 언어로 번역되지 않았습니다. 현재 작업 중이므로 곧 다시 확인해 주십시오.
Autocapture is the set of plugins Browser SDK 2 installs during init() to track common browser events without code. You control them with the autocapture option, and your Amplitude project's remote configuration can override your settings per feature. For a general introduction, go to Autocapture.
Choose a starting point
autocapture value | Features on |
|---|---|
| Omitted | The default set: attribution, page views, sessions, form interactions, file downloads, and page URL enrichment. |
true | The default set, plus element interactions, frustration interactions, network tracking, and web vitals. Performance tracking and experimental engaged time tracking stay off. |
false | None. |
| An object | The default set, with your changes. Set a feature to false to turn it off, or to true or an options object to turn it on. |
amplitude.init("AMPLITUDE_API_KEY", {
autocapture: {
elementInteractions: true,
fileDownloads: false,
pageViews: { trackHistoryChanges: "pathOnly" },
},
});
In a Chrome extension, the SDK turns off the default set. Set each feature you want to true. This default changed in 2.42.1.
autocapture replaces the deprecated defaultTracking option. If you set both, autocapture wins.
Features and events
| Feature | Option | Default | Events |
|---|---|---|---|
| Marketing attribution | attribution | On | $identify with campaign user properties, campaign event properties, optional [Amplitude] Attribution |
| Page views | pageViews | On | [Amplitude] Page Viewed |
| Engaged time tracking | engagedTimeTracking | Off | Adds engaged and total time to matching page-view events. Experimental; requires 2.52.0 or later. |
| Sessions | sessions | On | session_start, session_end |
| Form interactions | formInteractions | On | [Amplitude] Form Started, [Amplitude] Form Submitted |
| File downloads | fileDownloads | On | [Amplitude] File Downloaded |
| Page URL enrichment | pageUrlEnrichment | On | No event. Adds page properties to every event. |
| Element interactions | elementInteractions | Off | [Amplitude] Element Clicked, [Amplitude] Element Changed |
| Frustration interactions | frustrationInteractions | Off | [Amplitude] Rage Click, [Amplitude] Dead Click, [Amplitude] Error Click, [Amplitude] Thrashed Cursor |
| Network tracking | networkTracking | Off | [Amplitude] Network Request |
| Web vitals | webVitals | Off | [Amplitude] Web Vitals |
| Performance tracking | performanceTracking | Off | [Amplitude] Main Thread Block |
For every sub-option and default, go to Autocapture options in the configuration reference.
Remote configuration overrides local settings
By default, init() fetches your project's remote configuration from Amplitude before it installs plugins. You edit remote configuration in Data > Settings > Autocapture. For each feature that remote configuration sets, its value replaces yours. Features it doesn't set keep your local value. Remote configuration requires Browser SDK 2.10.0 or later, and its default changed to on in 2.16.1.
// Local configuration
amplitude.init("AMPLITUDE_API_KEY", {
autocapture: { pageViews: true, elementInteractions: true },
});
// Remote configuration: elementInteractions off, frustrationInteractions on
// Result: pageViews on, elementInteractions off, frustrationInteractions on
Remote configuration can turn on a feature even when you set autocapture: false. To make local settings final, turn off the fetch:
amplitude.init("AMPLITUDE_API_KEY", {
autocapture: false,
remoteConfig: { fetchRemoteConfig: false },
});
The fetch goes to https://sr-client-cfg.amplitude.com/config (or sr-client-cfg.eu.amplitude.com for EU). The SDK caches the response in the browser and applies whichever arrives first, the cache or the network. If an ad blocker or a Content Security Policy blocks the request, the SDK uses the cached copy, or your local settings when no cache exists. To route it through your own server, set remoteConfig.serverUrl (Browser SDK 2.28.0 or later).
Marketing attribution
Attribution reads UTM parameters, click IDs, and the referrer when the page loads. It records them in two independent ways, controlled by attribution.trackingMethod. Both run by default. The eventProperty method requires Browser SDK 2.40.0 or later, and the default changed to both methods in 2.45.0.
| Method | What it does | Use it for |
|---|---|---|
userProperty | Sends an $identify event that sets the campaign as user properties, and sets first-touch initial_* properties once. It sends the identify at the start of a session, or mid-session when the campaign changes. It stores the last campaign in an AMP_MKTG_ cookie. The identify also unsets campaign fields that the new campaign doesn't have, such as UTM parameters, click IDs, and referrer fields. | First-touch and last-touch attribution on the user |
eventProperty | Adds the current page's campaign parameters to the event properties of every event. It updates on page load and on SPA navigation. | Multi-touch attribution with persisted properties |
The SDK reads these parameters: utm_source, utm_medium, utm_campaign, utm_term, utm_content, utm_id, referrer, referring_domain, dclid, fbclid, gbraid, gclid, ko_click_id, li_fat_id, msclkid, rdt_cid, ttclid, twclid, and wbraid.
amplitude.init("AMPLITUDE_API_KEY", {
autocapture: {
attribution: {
trackingMethod: "userProperty",
excludeReferrers: [/example\.com$/, "checkout.partner.com"],
resetSessionOnNewCampaign: true,
},
},
});
These options apply only to userProperty tracking:
excludeReferrersignores campaigns from matching referring domains. By default it excludes your own domain and its subdomains. Setting it replaces the default, so include your own domain.excludeInternalReferrersignores referrers on the same domain as the page. Settrue(or{ condition: "always" }) to always ignore them, or{ condition: "ifEmptyCampaign" }to ignore them only when the URL has no UTM parameters or click IDs. Requires Browser SDK 2.36.0 or later.initialEmptyValueis the value forinitial_*properties that have no campaign value. The default is"EMPTY".resetSessionOnNewCampaignstarts a new session when the campaign changes.
fallbackAttributionEvent applies only to eventProperty tracking. Set it to true to send an [Amplitude] Attribution event on every page view, so campaign data arrives even if the user triggers no other event.
Single-page apps lose campaign context
In a single-page app, document.referrer doesn't change after the first load, and routers often strip the query string. Two consequences:
userPropertytracking reads the campaign only duringinit(). A campaign that appears later throughpushStatedoesn't update user properties.eventPropertytracking replaces the campaign on each navigation. After a user moves from/?utm_source=newsletterto/pricing, later events have noutm_source, but they keep the originalreferrer.
Initialize the SDK before your router rewrites the URL, and keep campaign parameters on server-side redirects. To drop the referrer after the landing page, add an enrichment plugin:
const landingUrl = location.href;
amplitude.add({
name: "drop-referrer-after-landing",
execute: async (event) => {
if (location.href !== landingUrl && event.event_properties) {
delete event.event_properties.referrer;
delete event.event_properties.referring_domain;
}
return event;
},
});
Page views
The SDK sends [Amplitude] Page Viewed when it initializes, and again when the URL changes through history.pushState(), the popstate event (back, forward, and hash changes), or, starting in version 2.49.0, history.replaceState().
Multi-step forms
A multi-step form that updates in place without changing the URL produces one page view. To track each step, add a hash to the URL for each step, for example with Google Tag Manager.
Each page view includes:
| Property | Value |
|---|---|
[Amplitude] Page Domain | location.hostname |
[Amplitude] Page Location | location.href, decoded |
[Amplitude] Page Path | location.pathname, decoded |
[Amplitude] Page Title | document.title, or ***** when the <title> element has a data-amp-mask attribute |
[Amplitude] Page URL | location.href without the query string |
[Amplitude] Page View ID | A UUID for this page view, shared with element interaction events on the page |
[Amplitude] Page Counter | The number of page views so far in this session |
| Campaign parameters | UTM parameters, click IDs, and referrer fields, when present |
Options:
trackOncontrols when to send page views. Omit it to send on every load and URL change. Set"attribution"to send a page view only when attribution sends a campaign. Set a function that returnstrueto send.trackHistoryChangescontrols which URL changes count. The default sends a page view on any change to the URL, including the query string and hash. Set"pathOnly"to ignore changes that keep the same origin and path.eventTyperenames the event.
amplitude.init("AMPLITUDE_API_KEY", {
autocapture: {
pageViews: {
trackOn: () => location.pathname.startsWith("/app"),
trackHistoryChanges: "pathOnly",
},
},
});
To add your own properties to page view events, use an enrichment plugin. For a working example, go to page-view-tracking-enrichment on GitHub.
Page titles in single-page apps
The SDK reads document.title right after pushState() returns. Routers in Angular, SvelteKit, React Router, and others often set the title after the URL changes, so the page view records the previous page's title. To fix this, turn off page views and track them from your router after it sets the title:
amplitude.init("AMPLITUDE_API_KEY", {
autocapture: { pageViews: false },
});
// Call from your router's navigation-end hook, after the title updates.
function trackPageView() {
amplitude.track("[Amplitude] Page Viewed", {
"[Amplitude] Page Domain": location.hostname,
"[Amplitude] Page Location": location.href,
"[Amplitude] Page Path": location.pathname,
"[Amplitude] Page Title": document.title,
"[Amplitude] Page URL": location.href.split("?")[0],
});
}
Page views you track yourself don't include [Amplitude] Page Counter or [Amplitude] Page View ID.
Engaged time tracking
Engaged time tracking measures how long a user actively interacts with a page while it has focus and remains visible. The Browser SDK adds cumulative engaged time and total elapsed time to matching page-view events, including custom event names. Use it to measure engagement with a single page, including visits without a second page view. Use standard page-view tracking when you only need to count page visits.
Engaged time tracking is an experimental feature in the stable SDK release. Its configuration and behavior can change. Contact your Amplitude account team before adopting it. The feature is free during the experimental period. Pricing for general availability isn't final.
Enable engaged time tracking
Requires @amplitude/analytics-browser 2.52.0 or later.
Set autocapture.engagedTimeTracking to true during initialization. The SDK includes the engagement plugin; you don't need to install it separately.
import * as amplitude from "@amplitude/analytics-browser";
amplitude.init("AMPLITUDE_API_KEY", {
autocapture: {
pageViews: true,
engagedTimeTracking: true,
},
});
During the experimental period, engaged time tracking is off by default, and autocapture: true alone doesn't enable it. Explicitly set autocapture.engagedTimeTracking to true or an options object to enable it. Set engagedTimeTracking to false to keep it disabled.
The engagement plugin waits for a matching event before it starts measuring time. With true or {}, it matches [Amplitude] Page Viewed. Matching is exact and case-sensitive. Other event types follow normal delivery.
Track a custom page-view event
If your application sends its own page views, disable automatic page views and set pageViewEventType to your event name:
import * as amplitude from "@amplitude/analytics-browser";
amplitude.init("AMPLITUDE_API_KEY", {
autocapture: {
pageViews: false,
engagedTimeTracking: {
pageViewEventType: "Article Viewed",
secondaryPageViewEventType: "Engagement Resumed",
},
},
});
// Send a matching event for the initial page and each navigation.
amplitude.track("Article Viewed", { article_id: "123" });
Engagement doesn't create the initial event. With automatic page views disabled, focus, interaction, and navigation can't start measurement until your application sends a matching event. If you rename automatic events with pageViews.eventType, also set engagedTimeTracking.pageViewEventType to that name.
How the SDK measures engagement
The SDK starts a rolling activity window when the engagement plugin processes a matching page-view event. Asynchronous enrichment can delay this start. The event keeps its original timestamp, but duration measurement starts when the plugin processes it, without backdating. Pointer presses, pointer movement, key presses, scrolling, touch starts, and wheel events refresh the window. Returning to the foreground also refreshes it.
With the default five-second window, an interaction credits up to five seconds of engaged time while the page stays visible and focused. Another interaction extends the window. Overlapping windows count once. After the window expires, time stops accumulating until another interaction. Hidden or unfocused pages don't accumulate engaged time.
For example, a user interacts three seconds after measurement starts on a focused page, then stops. The SDK counts up to eight seconds of engaged time. It doesn't count the overlapping windows twice. Passive reading without interaction stops contributing after the activity window expires.
The SDK sends cumulative snapshots every 15 seconds by default. A heartbeat sends the latest measurement; it doesn't count as user activity or extend the inactivity deadline.
When a page view ends
A logical page view ends when the plugin processes the next matching page-view event, the user leaves the document, or the inactivity timeout expires. SDK reset, user or device identity changes, session ID changes, and plugin teardown also end the active view. Entering the browser's back/forward cache ends the view. Restoring the page can start a fresh view in the foreground if the plugin previously accepted a matching event at that URL.
The default inactivity timeout is three minutes after the last activity. Returning before that deadline resumes the same view. Activity after the deadline starts a new logical view at the same URL. By default, the new event uses pageViewEventType, which can increase page-view counts. Set secondaryPageViewEventType to a different name, such as "Engagement Resumed", to distinguish these views from primary page views.
The SDK uses the secondary name for activity-based renewal after inactivity, identity or session changes, reset, and back/forward cache restoration. Each renewed view has a fresh timestamp and insert ID. Renewal doesn't copy the previous event's application properties, such as article_id or campaign fields. Normal SDK enrichment can add its own fields. Include both event names when reporting engagement across primary and renewed views. If the secondary name differs from the primary name, manually tracking the secondary name doesn't start engagement.
The timeout isn't a three-minute limit on total time. If the last activity occurs 20 seconds after a page view starts, the SDK finalizes it at three minutes and 20 seconds, unless another boundary ends it sooner.
For automatic page views in single-page applications, pageViews.trackHistoryChanges controls which URL changes send a matching event. Set it to "pathOnly" to track origin or path changes instead of query-string or hash changes.
For custom page views, send a matching event on each navigation. URL or history changes alone don't end the current engagement view or start another. After a URL change, automatic renewal waits for a matching page-view event at the new URL.
Configure timing
Pass an options object instead of true to customize timing. All durations use milliseconds.
import * as amplitude from "@amplitude/analytics-browser";
amplitude.init("AMPLITUDE_API_KEY", {
autocapture: {
pageViews: {
trackHistoryChanges: "pathOnly",
},
engagedTimeTracking: {
secondaryPageViewEventType: "Engagement Resumed",
activityWindowMillis: 5000,
heartbeatIntervalMillis: 15000,
inactivityTimeoutMillis: 180000,
},
},
});
For every option, type, default, and validation constraint, go to EngagedTimeOptions.
Engagement event properties
Engaged time tracking enriches each matching page-view event. Heartbeats update the same logical view instead of creating another analytics event. Each snapshot retains the event name, original timestamp, insert ID, identity, and session. Snapshots also retain application properties from the start of the view.
In normal initialization, the SDK captures page context after page-view and URL enrichment. Heartbeats preserve those page fields and don't increment the page counter. A renewed view passes through normal enrichment as a new event. Custom events don't gain a page counter if the page-view source is disabled or uses another name.
| Property | Type and unit | Meaning |
|---|---|---|
[Amplitude] Engaged Time | Number, milliseconds | Cumulative time within activity windows while the page is visible and focused. Excludes idle gaps and background time. |
[Amplitude] Total Time | Number, milliseconds | Elapsed time from the start of the logical page view to its latest snapshot or finalization. Includes idle and background time within that view, capped at its inactivity deadline. |
Divide either property by 1000 to express it in seconds. For average engaged time per view, average [Amplitude] Engaged Time over events that contain the property. If you configure a secondary event name, choose whether your report includes primary views, renewed views, or both. Standard page views without engaged time tracking don't contain this measurement, so don't treat a missing property as zero.
Snapshots contain cumulative values for one logical page view. Don't sum successive snapshots from the same view. [Amplitude] Snapshot Version and [Amplitude] Engagement Snapshot Reason are internal diagnostic properties, rather than stable reporting dimensions.
Compare with built-in time spent metrics
The SDK's duration properties and Amplitude's built-in Time Spent metrics measure different things. Built-in metrics calculate time from event timestamps at query time. They don't use [Amplitude] Engaged Time or [Amplitude] Total Time.
| Measurement | How it calculates time | Idle and background time | Single-page visits and final page views |
|---|---|---|---|
SDK [Amplitude] Engaged Time | Accumulates activity windows for each logical page view in the browser. | Excludes time outside an activity window and time when the page is hidden or unfocused. | Can measure engagement without a subsequent page view, subject to snapshot delivery. |
SDK [Amplitude] Total Time | Measures elapsed time from the start of a logical page view to its latest snapshot or finalization. | Includes idle and background time within the view, up to its inactivity deadline. The default deadline is three minutes after the last activity. | Can measure elapsed time without a subsequent page view, subject to snapshot delivery. |
| Built-in Time Spent metrics | Calculate the duration between consecutive matching events. Gaps over 30 minutes don't contribute time. | Don't directly observe browser focus or interaction. Idle and background time can contribute when it falls between matching events within the timeout. | Don't attribute time to a lone matching event or the final matching event because neither has a subsequent matching event. |
For the same SDK page view, engaged time can't exceed total time. Neither SDK property has a fixed higher-or-lower relationship with the built-in metric:
- Built-in time can be higher: A user opens a focused page, stops interacting, and triggers the next matching page-view event ten minutes later. The built-in metric can attribute the ten-minute gap to the first page. With default settings, the SDK credits up to five seconds of engaged time and finalizes the first view after three minutes without activity.
- SDK time can be higher: A user interacts with a single page for 20 seconds and then leaves. The SDK can record positive engaged and total time through its snapshots. With only one matching page-view event, the built-in metric attributes no time. Gaps over the built-in metric's 30-minute timeout can also cause it to report less time than the SDK.
Grouping and averaging can introduce further differences. Built-in Time Spent attributes an interval to the group-by property value on its starting event. Its per-user, per-page, and per-session averages use users, time-spent windows, or sessions with non-zero time spent. An average of the SDK property over measured page views can include views with zero engaged time. An SDK inactivity timeout can also split one visit into multiple logical page views.
When comparing charts, align the selected events, filters, group-by properties, date range, units, and averaging denominator. Account for delayed ingestion before comparing recent data. These measurement rules explain why the values needn't match; they don't establish the cause of a particular discrepancy.
Engagement delivery and limitations
Page views with engaged time tracking use delayed ingestion so the final event can include accumulated time. Don't expect the page-view event to appear immediately after page load or after each heartbeat.
The SDK sends a final snapshot at the end of the view. If it can't deliver that snapshot, the service falls back to the last accepted snapshot after expiration. Processing is asynchronous and best effort, with no guaranteed ingestion latency. The recorded durations don't include the wait for service expiration or ingestion. A missing final snapshot can omit engagement since the last accepted snapshot.
- User properties: Engaged page views omit
user_propertiesto prevent delayed events from overwriting newer updates. Send user-property changes through a separate Identify call. - Consent: Calling
setOptOut(true)discards the active engagement state and stops its heartbeats. - Network access: By default, delayed events use a dedicated regional endpoint, selected by
serverZone:https://delayed-events.prod.us-west-2.amplitude.com/2/httpapi/delayedfor US projects orhttps://delayed-events.prod.eu-central-1.amplitude.com/2/httpapi/delayedfor EU projects. With a customserverUrl, the SDK appends/delayedto that URL. SettingdelayedEventsServerUrloverrides both defaults and the customserverUrl. If you use a proxy or network allowlist, permit requests to the endpoint that applies to your configuration. - Custom enrichment: Plugins registered after engagement run again on every snapshot. Their returned properties don't automatically update the saved source event, so their values can change between snapshots. Avoid mutating nested application properties after tracking.
- Invalid or oversized events: If the SDK can't serialize or queue a snapshot, it sends the original event normally without engaged time tracking.
- Browser lifecycle: Browser suspension, network failures, and page exit can prevent final delivery. Use the measurements as best-effort engagement data.
Verify engaged time tracking
- Open a test page in a visible, focused browser tab. Confirm the SDK or your application sends the configured
pageViewEventType, then interact for more than 15 seconds. - Check the browser's network panel for periodic requests to the delayed-event endpoint.
- Switch tabs. Engaged time should stop increasing while the test page is in the background.
- Return and interact before the inactivity timeout to continue the same view. Repeat after the timeout and confirm the renewed view uses
secondaryPageViewEventType, or the primary event name if you omit the secondary name. - Navigate away and allow time for ingestion. Inspect the page-view event for
[Amplitude] Engaged Timeand[Amplitude] Total Time, both in milliseconds.
Sessions
The SDK sends session_start when a session begins and session_end for the previous session when the next one begins. Amplitude displays them as [Amplitude] Start Session and [Amplitude] End Session. With sessions: false, the SDK still assigns session IDs to events. For session rules, go to Identity and sessions.
Form interactions
The SDK tracks <form> elements:
[Amplitude] Form Startedon the first change to any field in the form.[Amplitude] Form Submittedon submit. If the user submits without changing a field, the SDK sendsForm Startedfirst.
Both events include [Amplitude] Form ID, [Amplitude] Form Name, and [Amplitude] Form Destination (the form's action URL).
Forms with the novalidate attribute fire submit even when the input is invalid. To decide which submits count, pass shouldTrackSubmit (Browser SDK 2.34.0 or later):
amplitude.init("AMPLITUDE_API_KEY", {
autocapture: {
formInteractions: {
shouldTrackSubmit: (event) =>
(event.target as HTMLFormElement).checkValidity(),
},
},
});
File downloads
The SDK sends [Amplitude] File Downloaded when a user clicks an <a> element whose URL path ends in one of these extensions: pdf, xls, xlsx, doc, docx, txt, rtf, csv, exe, key, pps, ppt, pptx, 7z, pkg, rar, gz, zip, avi, mov, mp4, mpg, mpeg, wmv, mid, midi, mp3, wav, or wma. It watches links added after load too.
Properties: [Amplitude] File Extension, [Amplitude] File Name (the URL path), [Amplitude] Link ID, [Amplitude] Link Text, and [Amplitude] Link URL.
Page URL enrichment
Page URL enrichment adds page context to every event, including custom ones: [Amplitude] Page Domain, [Amplitude] Page Location, [Amplitude] Page Path, [Amplitude] Page Title, [Amplitude] Page URL, [Amplitude] Previous Page Location, and [Amplitude] Previous Page Type. It doesn't overwrite a property the event already has. For details, go to Page URL enrichment plugin. Requires Browser SDK 2.22.0 or later, and the default changed to on in 2.29.0.
If you turn off Autocapture, you can still add the plugin yourself:
import { pageUrlEnrichmentPlugin } from "@amplitude/plugin-page-url-enrichment-browser";
amplitude.add(pageUrlEnrichmentPlugin());
amplitude.init("AMPLITUDE_API_KEY", { autocapture: false });
Element interactions
Element interactions send [Amplitude] Element Clicked and [Amplitude] Element Changed for interactive elements. Visual labeling and Zoning Insights depend on these events. For the data collected and how text masking works, go to Autocapture privacy and security.
By default the SDK tracks clicks and changes on a, button, input, select, textarea, label, video, audio, [contenteditable="true"], [data-amp-default-track], and .amp-default-track. It also tracks clicks on div, span, and h1 through h6 when the click changes the DOM or navigates.
import * as amplitude from "@amplitude/analytics-browser";
amplitude.init("AMPLITUDE_API_KEY", {
autocapture: {
elementInteractions: {
cssSelectorAllowlist: [
...amplitude.Types.DEFAULT_CSS_SELECTOR_ALLOWLIST,
".track-me",
],
pageUrlExcludelist: [/\/admin\//],
dataAttributePrefix: "data-analytics-",
},
},
});
cssSelectorAllowlistreplaces the default list. SpreadDEFAULT_CSS_SELECTOR_ALLOWLISTto extend it. Import it asamplitude.Types.DEFAULT_CSS_SELECTOR_ALLOWLISTfrom@amplitude/analytics-browser;@amplitude/plugin-autocapture-browserdoesn't export it.actionClickAllowlistreplaces thediv,span, and heading list for clicks that change the page. Set[]when you narrowcssSelectorAllowlist, so only your selectors count.pageUrlAllowlistandpageUrlExcludelistlimit tracking by page URL. The exclude list wins.shouldTrackEventResolverdecides per element. When you set it, the SDK ignores the allowlists.dataAttributePrefixcaptures matchingdata-attributes as properties. The default isdata-amp-track-, sodata-amp-track-plan="pro"becomes theplanproperty.maskTextRegexmasks text that matches your patterns, in addition to the SDK's built-in masking.shadowDomEnabled(experimental) captures interactions inside open shadow roots, up tomaxShadowDomDepthboundaries (default1, maximum10). After it turns on, it stays on until the next full page load.
Event properties include [Amplitude] Element ID, [Amplitude] Element Class, [Amplitude] Element Tag, [Amplitude] Element Text (clicks only), [Amplitude] Element Href (clicks only), [Amplitude] Element Position Left, [Amplitude] Element Position Top, [Amplitude] Element Hierarchy, [Amplitude] Element Path (a CSS selector for the element), [Amplitude] Element Attributes, [Amplitude] Element Aria Label, [Amplitude] Element Parent Label, [Amplitude] Viewport Height, [Amplitude] Viewport Width, [Amplitude] Page URL, and [Amplitude] Page Title.
Frustration interactions
frustrationInteractions: true turns on rage clicks and dead clicks. Error clicks and thrashed cursor are off until you turn them on individually. Frustration interactions require Browser SDK 2.24.0 or later.
| Signal | Event | Definition |
|---|---|---|
| Rage click | [Amplitude] Rage Click | Four or more clicks on the same element, within 50 pixels, in one second. Tracked on any element. |
| Dead click | [Amplitude] Dead Click | A click on an interactive element that changes neither the DOM nor the URL within three seconds. |
| Error click | [Amplitude] Error Click | A click on an interactive element followed within two seconds by a JavaScript error, console error, or unhandled promise rejection. Properties include [Amplitude] Kind, [Amplitude] Message, [Amplitude] Stack, [Amplitude] Filename, [Amplitude] Line Number, [Amplitude] Column Number, and the clicked element's properties, such as [Amplitude] Element Text. |
| Thrashed cursor | [Amplitude] Thrashed Cursor | Rapid back-and-forth pointer movement: 20 direction changes (minimum 5) within 2,000 ms (maximum 4,000). The SDK counts X-axis and Y-axis direction changes separately. |
amplitude.init("AMPLITUDE_API_KEY", {
autocapture: {
frustrationInteractions: {
rageClicks: true,
deadClicks: { cssSelectorAllowlist: ["button", "a"] },
errorClicks: true,
thrashedCursor: { directionChanges: 12, threshold: 1500 },
},
},
});
Dead clicks and error clicks use the interactive-element lists DEFAULT_DEAD_CLICK_ALLOWLIST and DEFAULT_ERROR_CLICK_ALLOWLIST unless you set cssSelectorAllowlist. For the selectors, go to frustration-interactions.ts on GitHub.
Each signal also accepts pageUrlAllowlist, pageUrlExcludelist, shouldTrackEventResolver, dataAttributePrefix, and maskTextRegex at the frustrationInteractions level.
Network tracking
Network tracking sends [Amplitude] Network Request for fetch and XMLHttpRequest calls. By default it captures only responses with status 500 through 599, and it ignores requests to Amplitude. Requires Browser SDK 2.17.0 or later.
amplitude.init("AMPLITUDE_API_KEY", {
autocapture: {
networkTracking: {
ignoreHosts: ["*.example-cdn.com"],
captureRules: [
{ statusCodeRange: "400-599" },
{
urls: [/https:\/\/api\.example\.com\/orders/],
methods: ["POST"],
statusCodeRange: "0,200-599",
responseHeaders: true,
responseBody: { allowlist: ["order/id", "order/status"] },
},
],
},
},
});
The SDK checks captureRules from last to first and applies the first rule that matches the URL, so put specific rules after general ones. Each rule accepts:
urls(string or RegExp, supports*) or the olderhosts. Omit both to match every URL.methods, for example["POST", "PUT"]. Default: all.statusCodeRange, a comma-separated list of codes and ranges. Default:"500-599".0matches requests that failed without a response.requestHeadersandresponseHeaders:truecaptures a fixed set of non-sensitive headers, such ascontent-typeandcache-control. An array captures exactly the names you list.requestBodyandresponseBody: JSON bodies only.allowlistlists JSON pointers to keep (*matches one key,**any depth).excludelistremoves keys the allowlist matched. The SDK captures no body content unless you set an allowlist.
For example, with this body:
{ "a": "A", "b": { "c": "C", "d": { "e": "E", "f": "F" } }, "g": "G" }
allowlist | excludelist | Captured |
|---|---|---|
["a"] | None | { "a": "A" } |
["*"] | None | { "a": "A", "g": "G" } |
["b/c"] | None | { "b": { "c": "C" } } |
["b/d/*"] | None | { "b": { "d": { "e": "E", "f": "F" } } } |
["b/**"] | None | { "b": { "c": "C", "d": { "e": "E", "f": "F" } } } |
["**/e"] | None | { "b": { "d": { "e": "E" } } } |
["b/**"] | ["b/d/f"] | { "b": { "c": "C", "d": { "e": "E" } } } |
Event properties: [Amplitude] URL (with sensitive parts masked), [Amplitude] URL Query, [Amplitude] URL Fragment, [Amplitude] Request Method, [Amplitude] Status Code, [Amplitude] Error Code, [Amplitude] Error Message, [Amplitude] Start Time, [Amplitude] Completion Time, [Amplitude] Duration, [Amplitude] Request Body Size, [Amplitude] Response Body Size, and, when configured, [Amplitude] Request Body, [Amplitude] Response Body, [Amplitude] Request Headers, and [Amplitude] Response Headers.
Web vitals
Web vitals sends one [Amplitude] Web Vitals event per page load, when the tab first becomes hidden. It includes [Amplitude] LCP, [Amplitude] FCP, [Amplitude] INP, [Amplitude] CLS, and [Amplitude] TTFB when the browser reports them, plus the page domain, location, path, title, and URL. For metric definitions, go to web.dev: LCP, FCP, INP, CLS, and TTFB. Requires Browser SDK 2.20.0 or later.
In single-page apps, set webVitals: { reportSoftNav: true } (experimental) to also send one event per soft navigation. This requires the Soft Navigations API (Chromium 151 and later). Other browsers report only the initial load.
Performance tracking
Performance tracking sends [Amplitude] Main Thread Block when the main thread stays busy for at least 100 ms. It uses the Long Animation Frames API where available and falls back to Long Tasks. autocapture: true doesn't turn it on. Requires Browser SDK 2.41.0 or later.
amplitude.init("AMPLITUDE_API_KEY", {
autocapture: {
performanceTracking: {
mainThreadBlock: { durationThreshold: 200 },
},
},
});
이 내용이 도움이 되었나요?
For AI agents: a documentation index is available at /docs/llms.txt. Append .md to any page URL for markdown, or send Accept: text/markdown.