1. Open the Segment Editor
To create a new Segment within the Matomo dashboard, you need to click on the button labelled All Visits in the data selector section shown below. The text label for this button is always set to the current segment, which in this case includes all visitors to the site.
Clicking the segment selector opens a dropdown menu which gives the list of available Segments, including the default All visits, plus any custom segments shared with you or that you’ve created. To start building a new segment, click the big green Add New Segment button which will load the Segment editor.
2. Segment Configuration
Within the Segment Editor, you will notice a small line of text along the top with dropdowns indicated by green arrows. The first dropdown lets you toggle between creating a new segment or editing an existing one. The remaining dropdowns show segment configuration settings with the current settings in bold. You can edit each setting by clicking the green dropdown arrow to its right. In most cases you won’t need to edit these, but it is useful to know what they do and where to find them.
Sharing a segment with all users
By default, any segment created by a user is only viewable by the user who created it, as well as by all Super Users. When creating a segment, at the top of the Segment Editor it says by default “This segment is visible to me”. You can choose to share the segment with “All Users” by selecting “This segment is visible to all users”. A segment shared with all users will appear in the list of segments for all users when they view their Matomo reports. Note: sharing a segment with all users is only accessible to Super Users.
Reusing segments across other websites
By default, a segment is created on a specific website (the current website you are viewing). When editing the segment, at the top of the segment editor it says “This segment is processed for this website only”. You can choose to share the segment across all websites by selecting “This segment is processed across all websites”. When you share a segment across all websites, the segment will appear in the list of segments on all websites. Note: sharing a segment with all users is only accessible to Super Users.
Improve the performance of your site while using Segments.
Last but not least, you will see an option to decide whether segments are processed in real-time or pre-processed (which requires a cron job). The latter option will only be present if you are using a self-hosted version of Matomo as it requires server access. This feature is especially useful if your site has a lot of traffic as the default “real-time” option may lead to slow loading reports.
3. Defining Your Segment
Next, you can begin creating the segment definition itself using the editor shown below. Begin by adding a clear and descriptive Name that you will use to identify your segment. For example, Customers or Returning Visitors as shown below.
To define exactly what group of visitors will appear within the segment, you will need to build a filter based on elements of your collected user and visit data. You can even combine more than one filter with a logical OR / AND flow.
You can review the available criteria that can be used to define a segment by clicking on the initial dropdown field on the first row. You can identify this field as it will state Actions in Visit by default, however, clicking it will bring up the following list in a box.
There are too many options available to cover in this article, so you should spend some time exploring the list of segment filters to discover them all. If you already know exactly what you want to filter by, you can use the search box to find the relevant user or visit data. You can also see a list of all segment filters available here.
Once you’ve selected a dimension to segment, for example; Visit Location > Country or Visitors > Visit type, you need to set the filtering criteria. You may notice a small question mark next to many of the filtering criteria. Hovering over these icons will display a full description of the relevant matching criteria.
As an example, if you wanted to create a Returning Visitors from UK segment. First you’d set the first dropdown to Visit type, the second to Is and the final text box to returning. Next, you would click + Add AND condition to combine filtering options.
Within the new section; select Visit Location > Country for the first dropdown, then Is for the second and finally United Kingdom in the text box as shown below.
When you begin typing a value in one of the text boxes for the filtering criteria, Matomo will suggest available options from the data set. You can click on these suggestions where possible to ensure the correct formatting and avoid potential typos.
After you have finished building your filter criteria, you can press the TEST button to bring up a log of all visits matching your Segment. If the details look correct, you can close the visits log popup and hit the green Save & Apply button at the bottom of the Segment editor. Build Custom Segments in Matomo