Event Sequence Timer

Last updated:

|Edit this page

🚧 Note: New installs of this transformation are currently disabled as we develop our new transformation functionalities.

You can still analyze the timing of event sequences using HogQL. For example, to get the average time between a $pageview and $pageleave events this year, create an SQL insight and use the following SQL statement:

SQL
SELECT avg(time_between) AS avg_time_between
FROM (
SELECT
dateDiff('minute', first_timestamp, next_timestamp) AS time_between
FROM (
SELECT
distinct_id,
event AS first_event,
timestamp AS first_timestamp,
first_value(event) OVER w AS next_event,
first_value(timestamp) OVER w AS next_timestamp
FROM events
WHERE
toYear(timestamp) = 2023
AND (event = '$pageview' OR event = '$pageleave')
WINDOW w AS (PARTITION BY distinct_id ORDER BY timestamp ASC ROWS BETWEEN 1 FOLLOWING AND 1 FOLLOWING)
ORDER BY distinct_id, timestamp
) AS subquery
WHERE first_event = '$pageview'
AND next_event = '$pageleave'
)

This can be customized with different events or properties. See an example use case in our “How to calculate time on page” tutorial.

If there is functionality around event sequence timing you want but don’t see a way to do, let us know by asking a question in our community.

What does this transformation do?

This transformation measures the time it takes for a user to perform one event (EventB), after an earlier event (EventA).

Requirements

Using this requires either PostHog Cloud with the data pipelines add-on, or a self-hosted PostHog instance running a recent version of the Docker image.

Installation

  1. In PostHog, click the "Data pipeline" tab in the left sidebar.
  2. Search for 'Event Sequence Timer' and select the transformation, press Install.
  3. Follow the on-screen steps to configure the transformation.

Configuration

First, you must configure the list of events to track time differences on. This list is specified as follows:

(eventA,eventB),(eventC,eventD),(eventA,eventD)

Where the first event in a tuple is the event that "starts the timer" and the second event being the one that "finishes it". In other words, the first event happens before the second.

You can further configure the transformation using the 'Update timestamp on every new first event?' setting. The default behaviour is 'Yes'.

If you select 'Yes', the stored timestamp for the first event will always be updated when a new event with the same name comes in (for the same user). This means your second event will always contain the difference between its time and the last time the user triggered the first event.

If you select No, the stored timestamp will only be set once and never updated. This means you will get the difference between the time of the second event and the first time the user triggered the first event.

How does the Event Sequence Timer show elapsed time?

The Event Sequence Timer transformation measures time between two events (EventA and EventB) in milliseconds.

When a sequence is completed, the Event Sequence Timer adds a new property called time_since_eventA to EventB. You can then use this property in analysis with other PostHog transformations.

Parameters

OptionDescription
List of events to track time differences on
Type: string
Required: True
Format:(eventA,eventB),(eventC,eventD) Spaces are not allowed
Update timestamp on every new first event?
Type: choice
Required: False
Selecting 'Yes' will track last touch, while selecting 'No' will track first touch.

FAQ

Is the source code for this transformation available?

PostHog is open-source and so are all transformations on the platform. The source code for the Event Sequence Timer is available on GitHub.

Who created this transformation?

We'd like to thank PostHog team member Yakko Majuri for creating the Event Sequence Timer. Thanks Yakko!

Who maintains this?

This is maintained by PostHog. If you have issues with it not functioning as intended, please let us know!

What if I have feedback on this destination?

We love feature requests and feedback. Please tell us what you think.

What if my question isn't answered above?

We love answering questions. Ask us anything via our community forum.

Questions?

Was this page useful?

Next article

Filter event properties

This transformation sets all specified properties on ingested events to null , effectively preventing PostHog from collecting information you do not want it to use. It is used by teams such as WittyWorks to protect user privacy by removing unneeded geographic data. Installation Log in to your PostHog instance Click " Data pipeline " in the left sidebar Search for 'Property Filter' press 'Install' Configure the by transformation by following the onscreen instructions. Note: This…

Read next article