What event tracking is
A pageview tells you someone opened your pricing page. An event tells you they clicked Start free trial on it, picked the yearly plan, and submitted the signup form. Each of those is an event: a name, a time, the visitor who did it, and a few properties such as plan: "pro".
Events turn analytics from a list of pages into a record of behavior. They are the raw material for goals, conversion funnels and conversion rate beyond purchases.
Three ways to collect events
- Automatic events. The tracker records button clicks, form submissions, file downloads or scroll depth by itself once you switch them on. No code, but generic names.
- Tagged elements. You add an attribute such as
data-goal="signup_clicked"to a button. The tracker sends the event when it is clicked. - Code. You call a function such as
track("checkout_started", { plan: "pro" })from your JavaScript when something happens that the page alone can't see.
A fourth source is your backend. A click on Sign up only shows intent; the account exists only when your server creates it. Sending that event from the server (server-side tracking) makes it trustworthy and immune to ad blockers.
How to set up event tracking
- Start from the money. List the 3 to 6 steps between a first visit and a payment: viewed pricing, started signup, created account, activated, paid.
- Name events consistently: one style, such as
signup_started, and past or present tense everywhere. - Add properties that explain differences: plan, placement, experiment variant. Keep them few and stable.
- Test each event once in your browser and check that it shows up before relying on it.
Then read each event against revenue: of the people who did it, how many paid and how much? An event that buyers do far more often than non-buyers is worth pushing people toward.
Common event tracking mistakes
- Tracking everything. Hundreds of events nobody reads make the useful ones hard to find.
- Renaming events. Changing
signuptosign_upbreaks every chart and funnel that used the old name. - Counting clicks as outcomes. A click on a buy button is not a purchase. Record the purchase from the payment itself.
- Putting personal data in properties. Emails and names in event properties end up in reports and exports.
How MetricRaven tracks events
In MetricRaven an event is a goal. You can send one from the page with window.analytics.track(name, props) or the npm package's track(), tag elements with data-goal and data-goal-* properties, mark sections with data-scroll-goal, or switch on automatic events for clicks, forms and downloads. Your backend sends verified events with the secret key (server events). Page views and outbound link clicks can become goals with no code at all.
Payments come from your payment provider, not from a click event, and subscription changes such as trial_started are recorded as goals automatically. Each goal shows who completed it, how many of them paid afterwards and what they paid, broken down by property value. See Goals & funnels.
Questions
- What is the difference between a pageview and an event?
- A pageview records that a page loaded. An event records an action on or off the page, such as a click, a form submission or a signup, usually with properties that describe it.
- What events should I track?
- The few actions between a first visit and a payment: viewing pricing, starting signup, creating an account, activating and paying. Add others only when a question needs them.
- Do I need code for event tracking?
- Not always. Many tools record clicks, form submissions and downloads automatically, and page visits can become goals without code. Actions only your app knows about, like an account being created, need a line of code or a server call.
- Are events blocked by ad blockers?
- Browser events can be, when the analytics script is blocked. Serving the script from your own domain helps, and events sent from your server are never affected.