Capturing events

Last updated:

|Edit 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 enable you to visualize your events and actions . There are several different types of insights: Trends Funnels Retention Paths Stickiness Lifecycle SQL How to create an insight To create a new Insight, navigate to the insights tab and click on New insight . Then select the type of insight you'd like to create, customize it, and press save. You can then create dashboards to collect and present multiple insights in one place.

Read next article