Once your PostHog instance is up and running, the next step is to start sending events.
You can send custom events using capture
:
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:
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 witha
,button
,form
,input
,select
,textarea
, andlabel
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.
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.