How to enable event autocapture on PostHog

beginner 8 min read Updated 2026-03-18
Quick Answer

Event autocapture in PostHog can be enabled through the project settings by toggling the autocapture option and configuring the JavaScript snippet. This feature automatically tracks clicks, form submissions, and page views without manual event tracking code.

Prerequisites

  • PostHog account with admin access
  • PostHog JavaScript library installed on your website
  • Project created in PostHog dashboard
  • Basic understanding of web analytics concepts

Step-by-Step Instructions

1

Access your PostHog project dashboard

Log into your PostHog account and navigate to your project dashboard. Click on the Settings icon in the left sidebar, then select Project Settings from the menu.
Make sure you have admin permissions for the project to modify autocapture settings.
2

Navigate to autocapture settings

In the Project Settings page, scroll down to find the Autocapture section. You'll see options for Autocapture, Capture pageviews, and Capture pageleaves.
3

Enable autocapture features

Toggle the Autocapture switch to ON. This will automatically capture clicks, form submissions, and other interactions. Also enable Capture pageviews and Capture pageleaves if you want to track page navigation events.
Start with basic autocapture enabled and add more features gradually to avoid data overload.
4

Configure autocapture options

Expand the Advanced Options section to customize what gets captured. You can set CSS selector allowlist to capture only specific elements, or CSS selector denylist to exclude certain elements from tracking.

Example allowlist: .track-button, #signup-form
Use CSS selectors to focus on important user interactions and exclude sensitive form fields.
5

Update your JavaScript snippet

Go to Settings > Project Settings > Snippet and copy the updated JavaScript code. If autocapture is enabled, the snippet will include:

posthog.init('your-api-key', {
    api_host: 'https://app.posthog.com',
    autocapture: true
})
6

Deploy the updated snippet

Replace the existing PostHog snippet in your website's <head> section with the updated code. Make sure the autocapture: true option is present in the initialization configuration.
Test the implementation on a staging environment before deploying to production.
7

Verify autocapture is working

Visit your website and perform some interactions like clicking buttons or submitting forms. Return to PostHog dashboard and go to Events to see if $autocapture events are being recorded. You should see events with details about the captured interactions.
It may take a few minutes for events to appear in the dashboard after implementation.
8

Configure event filtering and processing

Navigate to Data Management > Actions to create custom actions from autocaptured events. You can also set up Event Properties filtering to organize and analyze the captured data more effectively.
Create meaningful action names and descriptions to make your analytics data easier to understand.

Common Issues & Troubleshooting

Autocapture events not appearing in dashboard

Check that the JavaScript snippet is properly installed and autocapture: true is set in the configuration. Verify there are no browser console errors and that your website can reach PostHog's servers.

Too many irrelevant events being captured

Use the CSS selector denylist in autocapture settings to exclude unwanted elements. Add selectors like .no-track, [data-private] to prevent capturing clicks on specific elements.

Sensitive form data being captured

Add form input selectors to your denylist: input[type="password"], input[name*="credit"], .sensitive-field. You can also disable form autocapture entirely in the settings.

Autocapture settings not taking effect

Clear your browser cache and ensure the updated JavaScript snippet is deployed. Check that you have admin permissions and that the project settings were saved successfully. Wait 5-10 minutes for changes to propagate.

Prices mentioned in this guide are pulled from current plan data and may change. Always verify on the official PostHog website before purchasing.