Event Tracking
Tracking Events is a very useful way to measure interactions your users make with your website content, which are not directly page views or downloads. Typically events are used to track clicks on elements in your pages such as menu, widgets, Flash elements, AJAX actions, or even actions within games or media content.
Anatomy of Events
An Event has four components. These values are displayed in your reports:
- Category
- Action
- Name (optional, recommended)
- Value (optional)
Viewing Events Reports
Go to Matomo (Piwik). In the menu click Actions and then Events.
Tracking Events
Javascript trackEvent()
To track an event, use the Javascript function trackEvent:
trackEvent(category, action, [name], [value])
It will log an event with an event category (Videos, Music, Games…), an event action (Play, Pause, Duration, Add Playlist, Downloaded, Clicked…), and an optional event name and optional numeric value.
For example to track a click on the Play button of the Documentary Thrive you may write in your Matomo JavaScript Tracking Code in your pages:
_paq.push(['trackEvent', 'Documentary', 'Play', 'Thrive']);
To track the progress of playing a particular movie, for example when 20% of the movie has been played already:
_paq.push(['trackEvent', 'Documentary', 'Play-20%', 'Thrive']);
You may also track numeric values for your event. Event value is often used to track ratings and scores of particular items, such as tracking a rating of 9.5 out of 10 for Thrive:
_paq.push(['trackEvent', 'Documentary', 'Rating', 'Thrive', 9.5]);
Matomo reports for events will include the Total Event value, the Average event value as well as the Minimum and Maximum value, for each Event Category and each Event Name and each Event Action.
See also the JavaScript Tracking Guide for Events.
Tracking Events with HTTP API
Use Event Tracking from any application or server, with the Tracking API. View the Event Tracking HTTP API here.
Requesting Events report data
You may use the Events API to request all data for Events, including any report combining Event Categories, Event names and Event actions (see &secondaryDimension=
parameter)
Other interactions
Events are used to track interactions which are not pageviews. You can track all kinds of interactions with Events, but in some cases we have created specific and better ways to measure specific interactions:
- Tracking downloads.
- Tracking outlinks (clicks on external websites).
- Tracking Video players and Audio players.
- Tracking Ads, HTML blocks using Content Tracking.