Analytics

Events, properties and traits

Everything is an event: what happened, what was true at that moment, and what you know about the person.

Events and properties

An event is a name plus its properties. The name says what happened; the properties say which one, and how. A music app records a song_played event, and the song, the band and how long it played are its properties:

JavaScript
inc("track", "song_played", { song_name: "Creep", band_name: "Radiohead", seconds: 238 });

The properties are the point

Every question you'll ask later is a property question: plays by song_name, revenue by plan, signups by offer. An event without the properties that tell one from another can't be broken down, so send them from the start, and never put the detail in the name (creep_played). Money events always carry revenue and currency; the message that reached the person (offer, subject) is a property too, which is what lets journeys split by message.

Name events in the past tense, object first (order_completed, song_played); name properties in snake_case and use the same name for the same thing on every event (plan, not plan_name here and tier there). Properties can be text, numbers, true/false, lists or objects, up to 32 KB per event. Numbers can be summed and averaged in Explore; any property can be a row, a breakdown or a filter.

Page views

The pixel records page_viewed on every page, including single-page-app navigation, with these properties: url, path, title, referrer, search, every utm_* parameter, and ad click IDs like gclid (with marketing consent). The part of a URL after # is never recorded.

People and identify

Visitors start anonymous. When someone logs in, identify joins their earlier visits to them, across devices, and sets traits: what you know about the person.

JavaScript
inc("identify", "user_123", { plan: "pro", name: "Sam" });

// On log out, start a new anonymous visitor
inc("reset");

Two different logged-in people are never merged, even on a shared device. Each person's page under Analytics → People shows their IDs, traits and activity.

Changing traits

Any event can change the person's traits as well, in this order:

OperationDoesExample
traitsSets values{ plan: "pro" }
setOnceSets values only if not set yet{ first_plan: "free" }
incrementAdds to numbers (subtract with negatives){ lifetime_song_plays: 1 }
unsetRemoves traits["trial_ends"]
JavaScript
inc("track", "song_played", { song_name: "Creep" }, { increment: { lifetime_song_plays: 1 } });

Every event also keeps a copy of the person's traits as they were at that moment, so Explore can answer “plays by plan at the time”, not just by today's plan. Use Trait at the time… in Explore's rows or filters.

Watch out

Incrementing a trait that holds text rejects that event, and nothing changes. Keep counters numeric.

The tracking plan

Analytics → Events lists every event name received, each event's properties and every trait, with their types (names and types only, never values). Admins describe them and approve the events they expect; properties seen with more than one type are flagged, so naming drift is easy to catch.