Last updated:

Looking for a tutorial about how to use Actions? Check out our guide to event tracking.

Actions are PostHog's way of organizing large amounts of Events into a more useful format. Actions consist of one or more Events that you have decided to label in a specific way for use in Insights and Dashboards.

Examples of Actions:

  • 'Clicked sign up button'
  • 'User created account'
  • 'Viewed pricing page'
  • 'Submitted payment form'

To view your full list of Actions, go to Data Management in the left-hand navigation sidebar and then click on the Actions tab.

Creating actions

Select element on site

The simplest way to create a frontend-based action is to visit your application and use the PostHog Toolbar to tag the elements that are relevant.

We have a full step-by-step tutorial available about using our Toolbar, with a specific section dedicated to creating actions from frontend elements.

Autocapture-based actions

Autocapture-based actions are based on frontend elements from your website, such as a button or an input. The easiest way to select them is with the 'Inspect element on your site' functionality described above. However, you can also set them manually if you wish by providing something to identify the element, like a selector.

Our Autocapture functionality will capture a lot of frontend elements by default, but you will need to manually set anything else you want to be captured. Currently, autocapture will capture any click or change of input or submission of a, button, form, input, select, textarea, and label tags. All other elements need to be set manually. This important to note if you deviate from established HTML practices, such as using a div as a button.

Autocapture is also conservative regarding input tags to prevent grabbing sensitive data. See Autocapture for more details.

There are three ways to match your elements:

  1. Text: The text on the element, if applicable. If you have buttons across your site, all saying ‘Sign Up’, you can track ALL of them, site-wide, as the same action, by choosing Text: "Sign Up" and not matching the URL.
  2. Only match if URL contains: The URL where this action needs to take place. If you choose to match the URL as well, it will track any button on that page if it contains the ‘Sign Up’ text (which could be more than one button).
  3. Selector: details below.

You can have more than one match type selected. Having multiple fields selected is an AND statement, so all of them will need to match an event for it to count as the action.

Matching selectors

You can use standard basic CSS selectors to uniquely identify the elements you care about. The following types of selectors are supported:

  • Recommended: Attribute selectors. Example:[data-attr="value"] will match elements that have the given attribute and value.
    Please note that special attribute operators (e.g. *, ~|, ...) are currently not supported. Combining multiple attribute selectors is also not supported.
  • ID selectors. Example: #special-link will match elements with ID "special-link".
  • Class selectors. Example: .important-link will match elements with CSS class "important-link".
  • Type selectors. Example: input will match any<input> elements.
  • Combinators are also supported (e.g. descendant or child combinators). Learn more about combinators. Examples: form > [data-attr="submit"] or button span.

Page views

Page views can match urls containing a string, based on a regex or match exactly.

Regex matching is commonly used for URLs containing id-s like /some/path/123/view, which could be matched by a regex like /some/path/\d+/view into a single action, allowing for further analysis in other areas of PostHog.

Custom events

Custom events can be sent to your PostHog instance via our API or one of our libraries.

It is possible for an action to match multiple events. To do this, click ‘Add another match group’ when you are creating your action. Actions with multiple events work based on OR operations. That means that an action like "Clicked Read More Button" OR "Clicked More Information Button" will trigger as soon as the user clicks either of the buttons. Both clicks are not required for the action.

Further reading

Want to know more about what's possible with Actions in PostHog? Try these tutorials:

Want more? Check our full list of PostHog tutorials.


Was this page useful?

Next article


Annotations allow you to leave notes on your charts that can help you understand the driving factors behind the changes that happen over time. You can use annotations to mark things like version releases and new blog posts, which helps you add helpful context on events that impacted your metrics. Why Annotations are useful The chart below shows a large spike in website traffic, which has been annotated to explain why that spike occurs. Annotations can be viewed by hovering over them. Annotations…

Read next article