Capturing events

Last updated:

|Edit this page

On this page

Once your PostHog instance is up and running, the next step is to start sending events.

You can send custom events using capture:

Web
posthog.capture('user_signed_up');

Tip: We recommend using a '[object][verb]' format for your event names, where '[object]' is the entity that the behavior relates to, and '[verb]' is the behavior itself. For example, project created, user signed up, or invite sent.

Setting event properties

Optionally, you can also include additional information in the event by setting the properties value:

Web
posthog.capture('user_signed_up', {
login_type: "email",
is_free_trial: true
})

Page views and autocapture

By default, PostHog automatically captures the following frontend events:

  • Pageviews, including the URL.
  • Autocaptured events, such as any click, change of input, or submission associated with a, button, form, input, select, textarea, and label tags.

If you prefer to disable these, set the appropriate values in your configuration options.

Single-page apps and pageviews

PostHog automatically sends pageview events whenever it gets loaded. If you have a single-page app, that means it only sends a pageview once (when your app loads).

To make sure any navigating a user does within your app gets captured, you can make a pageview call manually.

Web
posthog.capture('$pageview')

This automatically sends the current URL along with other relevant properties.

Event ingestion

It's a priority for us that events are fully processed and saved as soon as possible. Typically, events will be usable in queries within a few minutes.

Questions?

Was this page useful?

Next article

Creating insights

Insights are the main building blocks of product analytics. They enable you visualize your events and actions and analyze how people use your products. Types of insight Trends Trends enable you to track how metrics change over time and use formulas to create custom metrics. Funnels Use funnels to understand conversion between steps, identify possible causes of success or failure, and track how conversion changes over time. Retention Retention insights enable you to see how often users…

Read next article