Skip to main content

Autocapture on the Web

The Javascript, React, and Angular SDKs offer Autocaptured log events: We automatically track page views, clicks, form submission, performance and more, to limit the boilerplate code you have to write.

Attributes captured across all events:

Propertydescriptionexample value (strings)
valueUrl of the current pagehttps://www.example.com/utm=FALL_2024
tagNameTag name of the target elementbutton

"Click" events (auto_capture::click):

Propertydescriptionexample value (strings)
metadata.contentinnerText value of the clicked elementAdd to Cart
metadata.page_urlCurrent URL with path and parametershttps://www.example.com/?utm=FALL_2024
metadata.hrefLink to url if tag is <a>https://www.target-url.com/
metadata.[dataset keys]Data set values expandedmetadata.attributionKey=demoLink

"Page View" events (auto_capture::page_view):

Propertydescriptionexample value (strings)
metadata.queryParamsA json representation of query string params{\"utm\":\"FALL_2024\"}
metadata.referrerURL of the prior pagehttps://www.google.com
metadata.titleTitle of the current webpage from <title>Homepage
metadata.screen_widthWidth of the current screen in pixels3440
metadata.screen_heightHeight of the current screen in pixels1440
metadata.viewport_widthWidth of the browser window in pixels960
metadata.viewport_heightHeight of the browser window in pixels600

"Page View End" events (auto_capture::page_view_end):

Propertydescriptionexample value (strings)
valueCurrent URL with path and parametershttps://www.FULL-URL.com/?utm=FALL_2024
metadata.pageViewLengthtotal number of milliseconds spent on the page61370
metadata.scrollDepthpercentage of page scrolled (integer 0-100)47

"Form Submit" events (auto_capture::form_submit):

Propertydescriptionexample value (strings)
valueFixed string"form"
metadata.actionaction attribute on the form element/submit.php
metadata.formIdid attribute on the form elementuser-info
metadata.formNamename attribute on the form elementuser-info
metadata.methodHttp method on the form elementPOST

"Performance" events (auto_capture::performance):

Propertydescriptionexample value (strings)
metadata.dom_interactive_time_msTime until DOM is qualified as interactive as implemented by browser performanceTiming API1807.90
metadata.first_contentful_paint_time_msFirst contentful paint metric as implemented by browser performanceTiming API1523.90
metadata.load_time_msTotal load time as implemented by browser performanceTiming API2766.90
metadata.page_urlCurrent URL with path and parametershttps://www.FULL-URL.com/?utm=FALL_2024
metadata.transfer_bytesTotal number of bytes transferred in document body as implemented by browser performanceTiming API48360

Auto Capturing Data Attributes

Data attribute tags will automatically be added to the event metadata object. Note that this is available for click events only for now!

The metadata will be in the format of data-(camelCasedAttributeName). For example:

<button data-button-attribute="important button attribute">Add to Cart</button>
<a href="/checkout" data-a-tag-attribute="important a tag attribute">Checkout</a>

Metadata on the events tab will be

{
"content": "Add to Cart",
"data-buttonAttribute": "important button attribute",
"page_url": "http://localhost:4200/",
"sessionID": "7ccb4e03-3599-443e-8d41-4b89f7168728",
"tagName": "button"
}
{
"content": "Checkout",
"data-aTagAttribute": "important a tag attribute",
"href": "/checkout",
"page_url": "http://localhost:4200/",
"sessionID": "7ccb4e03-3599-443e-8d41-4b89f7168728",
"tagName": "a"
}

Event Filtering

If you need to filter out specific auto capture events, you can use the eventFilterFunc option in the StatsigAutoCapturePlugin. This allows you to selectively disable certain events based on their properties.

For example, to disable page view events while keeping all other auto capture events:

const client = new StatsigClient(
'client-key',
{ userID: 'a-user' },
{
plugins: [
new StatsigAutoCapturePlugin({
eventFilterFunc: (event) =>
event.eventName !== AutoCaptureEventName.PAGE_VIEW,
}),
],
},
);

The eventFilterFunc receives the AutoCaptureEvent object and should return true to keep the event or false to filter it out. You can filter based on eventName, value, or any property in the metadata.