Skip to main content

Durations and sessionization

info

View this example in Motif here.

After sessionizing the sequences, this example calculates the time between a user visiting the search page and starting a movie (watch_start).

Video

SOL query

// Split user sequences into sessions with an hour or more in between
match split Session()+
if duration(Session[-1], SUFFIX[0]) > 1h

// Match sequences that include search followed by watch_start, without home_page, favorites_page or top_movies_page in between
match search_page >> (^home_page, favorites_page, top_movies_page)* >> watch_start

// Calculate and save the time between visiting search and watching
set dur = duration(search_page, watch_start)

Key steps

  1. Match sequences where the user goes from the search page to watching a movie with anything in between.
match search_page >> * >> watch_start
  1. Don’t include cases where the user went back to the homepage, favorites or top movies before starting to watch (try our AI completion with a query like: “match two events without specific events in between”).
match search_page >> (^home_page, favorites_page, top_movies_page)* >> watch_start
  1. Break user sequences into sessions before we match on the desired pattern, so that our analysis is based on session and not user lifetime
match split Session()+
if duration(Session[-1], SUFFIX[0]) > 1h
  1. Calculate the duration and save it as a sequence dimension
set dur = duration(search_page, watch_start)
  1. Plot the duration values in a histogram.

duration