[object Object] Icon

Encoding
Learn how to create, start, manage and modify Encodings

[object Object] Icon

Player
Learn how to create, start, manage and modify Players

[object Object] Icon

Analytics
Learn how to create, start, manage and modify Analyticss

Docs Home
User shortcuts for search
Focus by pressing f
Hide results by pressing Esc
Navigate via   keys

Wed Sep 12 2018

Segmenting your audience

OverviewLink Icon

For sure it’s interesting to look at global metrics like the total number of users and impressions, but it’s even more valuable to analyze these metrics for certain segments of your audience. Segmented metrics give you insights about who uses your service where and how.

In this article you’ll get an overview of how you can segment your audience using the Bitmovin Analytics API.

By locationLink Icon

A straightforward segment are users watching your videos in certain countries. Before we start, make sure you’ve set up the Bitmovin JavaScript client according to the “Getting Started” guide.

If everything works, let’s count the impressions from Portugal:

1queryBuilder
2 .count('IMPRESSION_ID')
3 .between(fromDate, toDate)
4 .filter('COUNTRY', 'EQ', 'PT')
5 .query()

You can pass any 2-letter country code to the country filter.

If you’re interested in more specific results, we can also pass a region code:

1queryBuilder
2 .count('IMPRESSION_ID')
3 .between(fromDate, toDate)
4 .filter('COUNTRY', 'EQ', 'US')
5 .filter('REGION', 'EQ', 'CA')
6 .query()

This will count all the impressions from California. Note that region codes only make sense in the scope of a country, as the same code could be defined for a region of another country as well. Therefore you should always combine the region with a COUNTRY filter.

It’s even possible to query for single cities:

1queryBuilder
2 .count('IMPRESSION_ID')
3 .between(fromDate, toDate)
4 .filter('COUNTRY', 'EQ', 'FR')
5 .filter('CITY', 'EQ', 'paris')
6 .query()

Although not mandatory, it’s a good idea to query for the country as well. Otherwise your result will include impressions from the around 30 other cities named Paris around the world. Please only pass the english version of a city’s name and always convert it to lowercase.

By URLLink Icon

If your video platform runs on several domains, you can also segment your users by the domain they visited:

1queryBuilder
2 .count('IMPRESSION_ID')
3 .between(fromDate, toDate)
4 .filter('DOMAIN', 'EQ', 'bitmovin.com')
5 .query()

This query is particularly useful when you test your service locally or on a separate staging domain, as you can filter out these impressions easily for your production metrics:

1queryBuilder
2 .count('IMPRESSION_ID')
3 .between(fromDate, toDate)
4 .filter('DOMAIN', 'NE', 'localhost')
5 .filter('DOMAIN', 'NE', 'mystagingdomain.com')
6 .query()

If your video platform is organized hierarchically and this hierarchy is reflected in your URLs, you can utilize it for your queries as well:

1queryBuilder
2 .count('IMPRESSION_ID')
3 .between(fromDate, toDate)
4 .filter('PATH', 'CONTAINS', '/telenovelas/')
5 .query()

This query counts all video impression of videos accessed through a path containing /telenovelas/ – including the slashes. So impressions of videos at https://mysite.com/videos/telenovelas/secret-love would be counted, but no impressions of videos at https://mysite.com/videos/recent-telenovelas/secret-love.

You can use the same technique to exclude certain paths, for example your admin area:

1queryBuilder
2 .count('IMPRESSION_ID')
3 .between(fromDate, toDate)
4 .filter('PATH', 'NOTCONTAINS', '/admin/')
5 .query()

By deviceLink Icon

Bitmovin Analytics tracks several attributes which give you important cues about the devices your audience uses to watch videos on.

Screen width and screen height are important indicators for the kind of device. For example, devices with less than 500 pixels width and less than 900 pixels height are most likely smartphones. Therefore we can count the number of impressions from smartphones like this:

1queryBuilder
2 .count('IMPRESSION_ID')
3 .between(fromDate, toDate)
4 .filter('SCREEN_WIDTH', 'LT', 500)
5 .filter('SCREEN_HEIGHT', 'LT', 900)
6 .query()

To narrow down the query to only Android phones, let’s filter for the operating system as well:

1queryBuilder
2 .count('IMPRESSION_ID')
3 .between(fromDate, toDate)
4 .filter('SCREEN_WIDTH', 'LT', 500)
5 .filter('SCREEN_HEIGHT', 'LT', 900)
6 .filter('OPERATINGSYSTEM', 'EQ', 'Android')
7 .query()

Identifying your iPhone users is even easier:

1queryBuilder
2 .count('IMPRESSION_ID')
3 .between(fromDate, toDate)
4 .filter('DEVICE_TYPE', 'EQ', 'iPhone')
5 .query()

You can also use the DEVICE_TYPE with Android to query for specific devices:

1queryBuilder
2 .count('IMPRESSION_ID')
3 .between(fromDate, toDate)
4 .filter('DEVICE_TYPE', 'EQ', 'Moto Z Play')
5 .query()

For a full list of devices your audience uses to watch videos, group the impressions by device type:

1queryBuilder
2 .count('IMPRESSION_ID')
3 .between(fromDate, toDate)
4 .groupBy('DEVICE_TYPE')
5 .query()
6 .then(console.log)

This will yield a list of devices along with the respective number of impressions:

1{
2 rowCount: 13,
3 rows: [
4 ["iPad", 30],
5 ["PlayStation 4", 43],
6 ["Pixel", 1],
7 ["Samsung SM-T280", 1],
8 ["Samsung SMART-TV", 1],
9 ["Nexus 5", 5],
10 ["iPhone", 58],
11 ["LG-K220", 8],
12 ["Asus Z00LD", 12],
13 ["Lenovo P2a42", 8],
14 ["Moto G Play", 1],
15 ["Other", 13535],
16 ["HTC Desire 816G dual sim", 2],
17 ],
18 columnLabels: [{ key: "IMPRESSION_ID", label: "Impression id" }],
19}
20

By browserLink Icon

Another way to segment your users is by browser. You can query for video impressions in Chrome like this:

1queryBuilder
2 .count('IMPRESSION_ID')
3 .between(fromDate, toDate)
4 .filter('BROWSER', 'CONTAINS', 'Chrome')
5 .query()

Why did we use CONTAINS instead of EQ? Depending on the device, browsers may have different names. Chrome is called “Chrome”, “Chrome Mobile iOS” or “Chrome Mobile”, Firefox is called “Firefox” or “Firefox Mobile”, Safari is called “Safari”, “Mobile Safari” or “Mobile Safari UI/WKWebView”, and so on. Unless you’re interested in these details, you should use a CONTAINS query with the general browser name.

It’s even possible to query for a specific browser version:

1queryBuilder
2 .count('IMPRESSION_ID')
3 .between(fromDate, toDate)
4 .filter('BROWSER', 'CONTAINS', 'Chrome')
5 .filter('BROWSER_VERSION_MAJOR', 'EQ', '62')
6 .query()

To find out all browsers people use to watch videos on your platform, group by the browser in your query:

1queryBuilder
2 .count('IMPRESSION_ID')
3 .between(fromDate, toDate)
4 .groupBy('BROWSER')
5 .query()
6 .then(console.log)

As the result you’ll get an array of browsers along with the number of video impressions in the browser:

1{
2 rowCount: 16,
3 rows: [
4 ["Opera", 233],
5 ["Chrome", 9875],
6 ["Safari", 579],
7 ["UC Browser", 4],
8 ["Chrome Mobile iOS", 10],
9 ["Mobile Safari UI/WKWebView", 8],
10 ["Chrome Mobile", 123],
11 ["Samsung Internet", 10],
12 ["Edge", 250],
13 ["Other", 43],
14 ["Mobile Safari", 68],
15 ["IE", 62],
16 ["Vivaldi", 3],
17 ["Firefox Mobile", 2],
18 ["Firefox", 1821],
19 ["Chromium", 47],
20 ],
21 columnLabels: [{ key: "IMPRESSION_ID", label: "Impression id" }],
22}

By player sizeLink Icon

When you offer your users to watch videos in full screen, do they really do it? All it takes to find out is a single query:

1queryBuilder
2 .count('IMPRESSION_ID')
3 .between(fromDate, toDate)
4 .filter('SIZE', 'EQ', 'FULLSCREEN')
5 .query()

To count only windowed impressions, use

1queryBuilder
2 .count('IMPRESSION_ID')
3 .between(fromDate, toDate)
4 .filter('SIZE', 'EQ', 'WINDOW')
5 .query()

If you add both total numbers, most likely the sum will be higher than the total number of impressions. That’s because usually users can toggle between windowed and full screen mode. If they toggle while watching a video, the impression will be counted as both windowed and full screen.

To be more specific, you can also query for the video window dimensions directly:

1queryBuilder
2 .count('IMPRESSION_ID')
3 .between(fromDate, toDate)
4 .filter('VIDEO_WINDOW_WIDTH', 'EQ', 800)
5 .filter('VIDEO_WINDOW_HEIGHT', 'EQ', 450)
6 .query()

By many other attributesLink Icon

There is a plethora of other possibilities to segment your audience. For example, you could get only impressions from videos sent to Chromecast with .filter('IS_CASTING', 'EQ', 1) or impressions of live streams with .filter('IS_LIVE', 'EQ', 1).

For an extensive list of filter options, please consult the Bitmovin Analytics API docs.

Give us feedback