Skip to content

schaumamoiDistill GA4 events into per-user state

Feed each user's events into a still, from a JetStream stream or a database replay. Cut what doesn't matter, infuse what you know, draw off what's stale, and distill as many states as you have recipes. Proven against a shop full of generated traffic.

schaumamoi — a Woipertinger in a Bavarian hat reading a ticker tape: "Schau ma moi"

How it works ​

Events come in from wherever they live: a NATS JetStream stream as they happen, or a replay from a database. Each user gets a still, and every event is worked on once, on arrival:

feedevents go into the user's still, a batch at a time, in arrival order
cutwhat isn't worth keeping is cut, and gone
infusewhat is known about each kept event (its time, its session, its taste) is infused into it
distilla recipe reduces the still to a state, as often as you like, with any recipe
draw offwhat the still should no longer hold is drawn off, by composable rules

A shopper's month, fed into the affinity still and distilled two ways. This is the package's runnable example, output included:

go
still := affinity.New(nil)
for _, visit := range month {
    for _, request := range visit {
        still.Feed(affinity.Envelope(request), request.Events...) // a sesamy-go payload, as it comes
    }
}

vector := still.Distill(affinity.DefaultFade.Vector)                     // the taste
phases := still.Distill(affinity.Phases(affinity.DefaultPhaseThreshold)) // who, and when

still.DrawOff(affinity.Rules.InSession(month[0].ID()))                   // forget a visit

// fed 7 visits, kept 65 choices
// the vector leads with classic, the month is 1 phase
// forgetting the first visit draws off 9 choices

Exhibits from the tests ​

The exhibits are written by the test suite: every one is computed from the real code on every run, every product and persona shown by its image, every claim next to the test that checks it.

  • Catalog and Personas, at the top of their guide pages, and Shop and Journeys: the test shop, package by package
  • Distillery: how a still works, what it distills from the traffic, and what drawing off does to it
  • Affinity vector: how the personalization vector fades and follows a changing intent

Schau ma moi: Bavarian for "let's have a look". Or, at a distillery, a taste.