What is an event?
An event is any recordable interaction a user has in your application or website. Clicking a button, or visiting a page, is an event. Moving a mouse cursor isn't.
You can create custom events, but PostHog also autocaptures many basic events (e.g. pageviews) for you. See our autocapture docs for more on what it does and doesn't capture.
You can view recent events from the Activity page in PostHog, which can be set to automatically update every 30 seconds for a live view of activity in your app.
Default events and properties
You may notice that some events or properties are prefixed with $
and show a PostHog icon next to them – e.g., $pageview
, $feature_flag_called
, $current_url
, or $os_version
. This indicates that these are default PostHog events or properties.
Pageview events
$pageview
events are automatically sent when using the JavaScript snippet or SDK. You can disable this by setting capture_pageview: false
in the initialization config.
You can manually send pageview events by calling posthog.capture('$pageview')
. This is necessary for single-page applications like React, Next.js or Vue, since otherwise a pageview event is only sent for the first page.
Pageleave events
Similar to pageview, $pageleave
events are automatically sent. You can disable them by setting capture_pageleave: false
in the config. For single-page applications, you'll also need to manually send these events using posthog.capture('$pageleave')
.
Event filtering
You can filter events by properties and cohorts to focus on specific events that are occurring in your project.
While ingesting events, PostHog detects some type information for properties to allow more intelligent filtering, such as:
- Boolean
- Dates and Timestamps
- Numbers
- Strings
- Everything else
If you feel something has been detected incorrectly, you can manually change the type by going to Data management -> Properties
selecting an event, clicking on Edit
, and then changing the property type manually.
Boolean (true or false)
PostHog detects boolean values and allows filtering by only:
- equals
- doesn't equal
- is set
- is not set
Dates and Timestamps
PostHog detects several formats of string as dates and times:
- YYYY-MM-DD,
- Date and date and time strings from the ISO8601 standard,
- YYYY-MM-DD HH:mm:SS,
- DD-MM-YYYY HH:mm:SS,
- DD/MM/YYYY HH:mm:SS,
- YYYY/MM/DD HH:mm:SS
- the RFC 822 standard
In detection, day and month are interchangeable so MM-DD-YYYY would be detected as a date.
Ten and Thirteen digit numbers are detected as timestamps if the property name includes "time" or "timestamp"
Filtering against that property will then show a date picker and allows filtering only:
- equals
- before
- after
- is set
- is not set
See also: How PostHog calculates timestamps.
Numeric
PostHog detects numeric properties and allow filtering by only:
- equals
- doesn't equal
- matches regex
- doesn't match regex
- greater than
- lower than
- is set
- is not set
Strings (text)
PostHog detects text content. If it is not true/false, numeric, or a date time. You can filter by:
- equals
- doesn't equal
- contains
- doesn't contain
- matches regex
- doesn't match regex
- is set
- is not set
Push-based event tracking
Most users of PostHog will want to combine their back-end data, such as user information, with the front end actions of those users in their UI. There are three ways of passing data to PostHog:
Further reading
- How to trigger Discord notifications when an action is detected in PostHog
- How to automatically organize PostHog actions in Notion
- The complete guide to event tracking
Want more? Check our full list of PostHog tutorials.