Matomo (Piwik) tracks visitors to your website and displays reports describing who they are and how they behave. You can use these reports to find out:

These reports, however, show you information in the aggregate. That is, they combine and remove context from all the information Matomo tracks to provide you with a general overview.

So you can see that most of your visits come from one country, but you won’t be able to see what people in that country do on your website. At least, you won’t if you don’t use segments.

A segment is a set of criteria used to select only a part of the entire set of visits tracked by Matomo. Using the segments you define, Matomo will generate reports for only the visits the segment selects.

This means you can generate reports for everyone that visits from that one country and see how they use your website. Or you can generate reports for everyone outside of that country and see how their behavior differs. Or you can do any number of other things.

Using segments you can inject arbitrary context back into your reports and make the data Matomo tracks relevant to you and the things you care about.

Creating a segment in Matomo

To create a segment, first click the segment selector which can be seen on every non-admin page:


Click on ‘Add a new segment’ or on the ‘edit’ link next to an existing segment name to open the segment editor:

open_add_ new_segment

Click on any item on the left to see the list of information you can segment by:


You can also use the search box at the bottom to search through the whole list.

To create your segment, drag and drop the criteria on the left to the big white spaces on the right. After you do the drop, the segment editor will let you specify exactly what that bit of information should be when selecting visits:


If you’d like to select visits using more than one bit of criteria, you can do so by adding OR and AND conditions:


This segment will select all visits that discovered the website with a search that contains “piwik” and contains either “custom variables” or “site search”.

Click the Save & Apply button to save your segment. The segment will be immediately applied and the reports you view afterward will be on the visits your segment selected.

Switching between segments

To switch between segments, simply open the segment selector and select a segment:


The segment selector is displayed on every page with reports, so you can switch between segments anywhere you like.

Removing segments

To delete a segment, open the segment editor and start editing a segment. After the segment editor opens, click on the Delete link:


Using segments in e-mail reports

It is also possible to create e-mail reports that use a segment:


E-mail reports that use a segment will display the segment name at the top of the page.

Useful segments you can create

To get your creative juices flowing, here’s a list of segment ideas you might find useful:

Custom segment: Customers

See everyone who bought something from you.

Segment Definition

Visit Ecommerce status at the end of the visit is ordered OR Visit Ecommerce status at the end of the visit is orderedThenAbandonedCart

Questions to ask yourself

What content was most helpful at driving your sales? Did your customers maybe watch product videos before purchasing? Are customers reading reviews and for how long?

Custom segment: Returning customers

See everyone who bought something and then came back for more.

Segment Definition

Visit Ecommerce status at the end of the visit is ordered AND Number of Visits is greater than 1

Questions to ask yourself

What did everyone who bought something and came back look for? Did they find it and buy it? Or did they leave empty handed? If they left, did they come back or did they leave forever?

Custom segment: Bounced visits

See everyone who visited your website and immediately left.

Segment Definition

Number of Actions equals 1

Questions to ask yourself

What pages are these visitors visiting? What keywords were they using? Why do you think those pages didn’t answer their questions?

Custom segment: Mobile visitors

See everyone who accessed your website from a mobile device. Note: to access this segment, first enable the “DevicesDetection” plugin.

Segment Definition

Device type is smartphone OR Device type is tablet OR Device type is feature phone

Questions to ask yourself

Do you get a lot of visitors from mobile devices? Can they successfully navigate and use your website? What pages don’t they visit or spend much time on?

Custom segment: Commenters

See everyone who commented on your website.

Segment Definition

Custom Variable name 1 (scope visit) is commenter_id

Note: This segment depends first on setting up a Custom Variable.

Questions to ask yourself

What types of pages do visitors comment on most? Is there a set of visitors who regularly comment or are there a large number of visitors who comment once or twice and leave? Or do both exist?

Custom segment: Visits from the region your business is located in

See everyone who accessed your website from certain region.

Segment Definition

Country is xx AND Region is xx

Replace ‘xx’ with the appropriate country/region code.

Questions to ask yourself

Do you get a lot of visitors near your business? What information do they look for on your website?

Custom segment: Everyone who doesn’t bounce

See everyone who visited your website and stuck around.

Segment Definition

Number of Actions is greater than 1.

Questions to ask yourself

What do people who stick around on your website look for? How do they get to your website? Are they looking for something your website doesn’t provide?

Use your imagination, stay curious and you’ll stumble upon insights that will help you prosper.

Determining what to segment

For the most part, figuring out how to segment your data is a creative exercise. How you should segment depends entirely upon what you’re doing, what you want to achieve and what you want to know.

If you own a restaurant and are tracking visits to your restaurant’s website, you might be interested mainly in people who are located in the same area you are in. In this case, you might want to create a segment for these local visitors to learn more about them.

If, on the other hand, you own a blog that sells info-products, you might be more interested in how they get to your website than where they’re physically located. In this case, you might want to create segments for top performing keywords and referrers.

To create insightful segments, you need to be clear about what’s important to you, and curious about your existing visitors

Figuring out how to segment based on your objectives

  • Be very clear about what you want to accomplish. (In fact, set up some Goals to reflect your objectives.)
    Do you want to increase the amount of visits to your website? Do you want to provide your existing visitors with more value? Do you want to increase your sales? Do you want to find out why you get the sales you currently do? Ask yourself as many questions you can about what you want to achieve and make them as specific as possible.
  • Check if your objectives require you to look at a subset of all your possible visits.
    If you don’t need to look at some of your visitors, you don’t need a segment.
  • Based on the subset of visits you want to affect or find out more about, create a segment that selects them.
  • Repeat.
    As time goes on, your objectives will change, you’ll need different information, and thus, new segments.

An example:

Ashley is head of a chain of stores in the US.

  • Ashley gets clear about her goals.
    At the moment our stores are doing very well. Except for one. It’s a new store we’ve opened in Canada. Our sales there are half as much as we expected. I want to increase the sales received at our new store. In order to do this, I need to understand why they are not selling as well as our existing stores. I need to understand our potential customers, and since many of them will be looking at our store’s website for locations/products, I can analyze our website’s visitors to gain insights.
  • Ashley decides whether she needs to create a segment.
    I want to learn more about our potential customers in Canada. I want to learn how they differ from existing customers in the US. This means I will want to look at two subsets of our website’s visitors, which means I’ll need at least two segments.
  • Ashley creates some segments.
    I need one segment that selects visits from within Canada: Country is ca I also need one segment that selects visits from within the US: Country is us For completeness, I also want to look at visits that are from the region most of our stores are in: Country is us AND Region is WA

Figuring out how to segment based on your data

  • Make it a habit to ask questions about your data.
    What do people who come from that one website do on yours? What keywords do people who visit your site from that one country use? What do people who have already bought from your store do when they return to your website? The more information you have, the more actionable insights you’ll conjure.
  • Create a segment that selects the set of visits you want to know more about. Analyze the reports you’ve generated using your set of questions.
  • Repeat. Find out more about your visitors!

An example:

Simon is a master chef and owns a blog where he shares recipes.

  • Simon looks at his data and asks some questions. My blog has a group of steady commenters, but I see that there are a lot more visitors to my website. Yes, I get a lot of visits and most of them bounce. I wonder why they aren’t interested in my content?
  • Simon creates segments to answer his questions. I need a segment to see how the visitors who bounce behave: Number of Actions is equal to 1 I need a segment to see how those visitors differ from my returning visitors: Number of Actions is greater than 1
  • Simon gains insights. I see that all of my returning visitors use keywords like ‘good bolognese sauce’. They seem to know something about cooking already, whereas the visitors that don’t stick around use keywords like ‘meaty sauce’ or ‘how to cook meat’. It seems a lot of people who visit my website want to learn more about cooking in general, not find new recipes. Maybe if I write content for them, they’ll stick around. And maybe if I create info products for them, they’ll buy it.

Segments API Reference

  • List of all available Segments – The Segmentation API reference explains how to construct an API request using a Segment, and also lists all available segments, segment operators and more.

You may also manage Custom Segment using the following API methods to list, create and edit segments:

  • SegmentEditor.get – Returns a single stored segment by ID.
  • SegmentEditor.getAll – Returns all stored segments.
  • SegmentEditor.add – Adds a new stored segment. Query Parameters:
  • SegmentEditor.update – Modifies an existing stored segment.
  • SegmentEditor.delete – Deletes a custom segment
  • API.getSuggestedValuesForSegment – Returns a set of suggested values for use with a particular segment criteria (such as country, provider, etc.). See these methods in context in the SegmentEditor API documentation.