Chapter 02

Advanced tracking with events

By Anna Tomalik

When Piwik PRO tracks a visitor on your website it collects basic information about the session by looking at the page load. For example, Piwik PRO reads the page path (URL), page title, counts page views, time spent on a page, and sees where the user came from and which device they use.

However, a user may perform different actions on your website besides just loading a page. They can download an ebook or whitepaper. Click links that send them to external websites. Or click buttons with call to action. All these moves can’t be tracked based on a page load and need to be defined as events.

Ready-made events

In Piwik PRO, there are several ready-made events: a page view, search, outlink, download, content impression, content interaction, goal conversion, ecommerce conversion, and abandoned chart. We’ll describe a search, an outlink, and a download event.

The search event occurs when a visitor types a keyword in a search bar on your website and clicks a search result. During this event, Piwik PRO captures data about the keyword and sends it to Analytics. Later, the data appears in the internal search report (Analytics (new) > Reports > Internal search).

An internal search report in Analytics.

By default, internal search tracking is turned on for every website and tracks the most popular search query parameters. If you need to adjust the site search settings, go to Menu > Administration > Websites & apps > Pick a website > Settings > Site search tracking.

The outside link event, called outlinks in Piwik PRO, happens when a visitor clicks a link leading to an external website. This website may be a domain you track separately, for example, a help center or blog. Or it can be a foreign domain, for example, Facebook, YouTube, or Medium. Once a visitor follows an outside link, Piwik PRO passes information about this event to Analytics, and later the data appear in the outlink report (Analytics (new) > Reports > Outlinks).

An outlink report in Analytics.

The download event is when a visitor downloads a file from your website, such as a PDF or CSV. Piwik PRO sees when a visitor clicks a download link and informs Analytics about the event. Later, data for this event show up in the download report (Analytics (new) > Reports > Downloads). 

Just keep in mind that Piwik PRO doesn’t know if the file was fully downloaded, only that the visitor clicked a download link.

A download report in Analytics.

Set up a custom event

For any other event than listed above, you’ll need to set up a custom event using Tag Manager. Tag Manager is a sturdy and versatile tool that works together with Analytics. One of its powers is tracking data from events.

To define an event in Tag Manager you will have to set up a tag and trigger. A tag will count the events and collect information about each event such as event category, action, and optionally name and value. A trigger will tell a tag to fire, for example, when a user clicks a button a trigger will tell the tag: “Now, capture data about this event.” 

Once a tag and trigger are set, Tag Manager will pass information about an event to Analytics and you will see data about this event in an event report (Analytics (new) > Reports > Custom events).

Custom events explained on the illustration.

To define a tag for an event, follow these steps:

  1. Go to Menu > Tag Manager.
  2. In the left-side menu click Create new tag.
  3. Name the tag.
  4. Pick Piwik PRO Custom Event tag and click Save.
  5. Select custom event in Tag Manager.
  6. Set category, action, and optionally name and value. (We’ll explain these elements later in this chapter.)
  7. A custom event setup.
  8. Click Save.

To define a trigger for an event tag, follow these steps:

  1. Open the event tag for which you want to set up a trigger.
  2. Scroll down until you see Tag triggers.
  3. Click New trigger.
  4. Add new trigger in Tag Manager.
  5. Name the trigger.
  6. Select the event type for the trigger.
  7. On regular-size screens:

    A click trigger in Tag Manager.

    On small-size screens:

    A click trigger in Tag Manager.
  8. In Trigger conditions, set one or more conditions that need to be met for a tag to fire.
  9. Trigger conditions in Tag Manager.
  10. When done, click Save for the trigger and click Save for the tag.

To open debug mode, follow these steps:

  1. Go to Menu > Tag Manager.
  2. In the top-right corner click Debug.
  3. Click debug mode in Tag Manager.
  4. Your website will open in a new tab with debug mode running.
  5. The Clear Bank website in debug mode.
  6. Try to do a defined action, like click a button, and see if your tag is firing.

When you are happy with how the event works, you can publish the tag on your website.

To publish a tag, follow these steps:

  1. Go to Menu > Tag Manager.
  2. In the top-right corner click Publish.
Click a publish button in Tag Manager.

The tag will work straight away, but you will have to wait a bit to see an event in the event report because the data is being archived. However, if you look at the visitor log report, you’ll be able to spot users who perform events in real time (Analytics > Visitors > Visitor Log).

Category, action, name, and value

When adjusting how elements are tracked on your website you are defining four parameters: event category, action, name, and value. But you might not be sure what these are. Let us explain:

A custom event explained on the illustration.

A category organizes events you track into groups. For example Buttons, Videos, Social Shares, and more.

An action tells you what a user did. For example, clicked, played, shared, and more. If you were tracking when a user clicked a signup button, you might have a category called Buttons and an associated action called Click.

A name is an optional further description of the element you’re tracking, like the call-to-action on the button. For a signup button, a name could be Sign Up.

A value is an optional numerical value which you can add to the event. For example, a dollar amount. If an action is worth some money for your business, like a signup button click is worth 5 USD, you can assign a value for it. Every time an event happens, Piwik PRO will count the value and show the total value in an event report.

Parameters can be named manually — in other words, you can type the name in each parameter field and this name will show up in reports. But you can also define a custom variable for each parameter. A custom variable will pull out the data about the tracked element like click element, click ID, click URL, and more, and pass it on to reports.

To set up a custom variable for an event category, action, or name, follow these steps:

  1. Open your custom event tag.
  2. In Piwik PRO Custom Event setup, click (X) icon for category, action, or name and pick the custom variable you want.
  3. Add a name to a custom event.
  4. When done, click Save.

Event report

All data collected from custom events will appear in the custom event report (Analytics (new) > Reports > Custom events). It will be organized into three levels: event categories, actions, and names, and you will be able to drill down from one level to the other. In the event report, you will see the number of total events and the total value. Yet, setting the value for events doesn’t happen that often, so you may frequently see no data for that metric.

A custom event report in Analytics.

A good practice is to use a custom variable like a page path or page URL for an event name. You will then know on which page the event happened.

Examples of pages on which a button was clicked.

As you can see, custom events and event reports are tightly coupled. Data defined in one will pour into the other. Therefore, be mindful about how you name your categories, actions, and names, so when they show up in your reports the event data is easy for you and others to understand. It may take some practice to figure out the best framework for that, but you will get better with time.

We’ve gone through the basic setup for custom events. In the next few chapters we’ll look at how to track specific elements on your website like a button click, menu, contact form, page scroll, and video play.