Events

Last updated:

|Edit this page

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:

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

Want more? Check our full list of PostHog tutorials.

Questions?

Was this page useful?

Next article

Ingestion warnings

Sometimes PostHog runs into problems during ingestion due to incorrect or suboptimal usage of PostHog. For example, if you capture an event with a generic ID like null , PostHog doesn't ingest it. If this happens, we do our best to still ingest the event and we log an ingestion warning. Note: These warnings are sampled. The actual number of events affected may exceed the total displayed. List of ingestion warnings: Refused to merge with an illegal distinct ID Refused to merge an already…

Read next article