Chapter Summary: User Metrics
Assessing User Activity
These are the three main ways of measuring the number of active users:
- DAU — the number of daily unique users
- WAU — the number of weekly unique users
- MAU — the number of monthly unique users
Generally, these metrics increase steadily, so they play an important role in team motivation. For that reason, they're sometimes called vanity metrics.
There's also the sticky factor. This metric tells you how loyal the audience is—how often they return to the app. The formula is:
User Session
The time users spend with a product is measured per session. A session is the period between the opening and closing of the app.
Average session length, or ASL, is the amount of time users spend with a product in the average session. Whether a particular ASL is "good" depends on the nature of the product.
Metric Frameworks
Google's HEART framework is used to assess user experience (UX):
Happiness
Do users enjoy the product/service?
Engagement
How often do they use the product or write about it on social media?
Adoption
How many new users do we have?
Retention
How many users stay loyal to the service?
Task success
To what extent is the target action (subscription, purchase, adding to cart) performed successfully?
The HEART framework is often used because of its simplicity, and because the framework can be enhanced. It's usually used in conjunction with the Goals-Signals-Metrics approach.
The work process goes like this:
- Identify product goals.
- Answer the question "How will reaching the goals or failing to do so impact user behavior"?
- Decide how to measure signals.
Another handy framework is AARRR. AARRR helps you understand user traffic and optimize the funnel.
AARRR involves the following metrics:
Acquisition
Where do customers come from?
Activation
Did users complete a target action when they began interacting with the product?
Retention
How many customers continue using your product, and why do the others quit?
Referral
Are users ready to recommend your product?
Revenue
How can revenue be boosted?
Conversion is calculated at each stage. This allows you to see how successfully customers are being attracted and what factors influence purchases.
These frameworks help analysts by
- helping you understand the business you're analyzing.
- helping you carry out business tasks.
- helping you create your own framework.
Detecting Anomalies
The stages of investigating anomalies are:
- Collecting data and calculating the key metrics.
- Visualizing data.
- Separating the data with anomalous behavior.
- Studying data and searching for the reason:
- comparing the anomaly with other anomalies
- taking outside events into account
- analyzing competitors' problems
- data collection (how it was done, what may have gone wrong)
- allowing for seasonality, future releases, and major improvements
- Drawing conclusions.
Metrics can be affected by seasonality, holidays, and technical problems. Investigation have to be carried out when anomalies have already appeared in the data.
This process helps you reveal growing points.
Yandex.Metrica
Yandex.Metrica is a web analytics tool that helps track website sessions, assess user behavior, evaluate the performance of promotion channels, and carry out content analysis.
What can Yandex.Metrica tell you about users?
- Their age and gender
- Their interests
- The countries and cities they come from and the languages they speak
- The devices or browsers they use
- How loyal they are and how much money they bring
Yandex.Metrica provides summary analytics that tell you in detail how your website is doing.
You can find a demo account here.
On the left you'll see the tools panel.
Reports
Reports contain summary info on user demographics, interests, and behavior.
Maps
Heatmaps, form analysis, scrolling maps—all of this helps give you a visual understanding of the data.
Session Replay
Session Replay records a session as seen by the user. Viewing such records helps you understand user behavior and detect difficulties users may encounter.
Users
You'll learn who visits your website, how much time they spend on it, and whether they make purchases.
Yandex.Metrica helps you solve multiple tasks:
- Finding problems on the website
- Recreating user journeys on the website
- Marketing analytics
- Analytics for online stores
Yandex.Metrica API
You can use the Logs API to get non-aggregated data collected by Yandex.Metrica.
The aggregated or summary data that you see in the Metrica interface or export from API reports is calculated for a specific group of sessions. The basis for these calculations is raw data: the records on individual sessions or page views. Tables containing these records can be obtained through the Logs API, and each record contains useful information from Metrica. Here we have data on Yandex.Direct and e-commerce and on users' countries and cities. The raw data also includes technical information on sessions.
To access Metrica through the Logs API, you need to get authorized using an access token. The access token must be specified in every API request.
Learn how to register apps for accessing data and get an access token from the support page.
The easiest way is to get a debugging token for authorization. Read more here.
Import the requests
library, make a GET request, and store the results in r
.
Notice that in addition to params
, the get()
method also takes the headers
parameter. It contains HTTP headers—service data that sends additional information to the server. We've specified the access token in the 'Authorization'
HTTP header.
1import requests2r = requests.get(URL,headers={'Authorization': 'OAuth {0}'.format(TOKEN)},params=PARAM)
The evaluate method evaluates the possibility of creating a logs request based on its approximate size.
Here's how evaluate
requests look:
1<https://api-metrika.yandex.net/management/v1/counter/{counterId}/logrequests/evaluate>2 ? [date1=<string>]3 & [date2=<string>]4 & [fields=<string>]5 & [source=<log_request_source>]
counterId
in the URL is the counter identifier.
The following GET request parameters are also passed:
date1
— the start date for statistics collectiondate2
— the end date (can't be the current date)fields
— a list of fields separated by commas. This parameter specifies the fields from the Yandex.Metrica base that are to be retrievedsource
— log source. Can take one of the two following values:visits
orhits
. Depending on which value is entered, data will be retrieved either by sessions/visits or by hits (views of specific pages, the accomplishment of specific goals...)
The response page contains data in JSON format. The main information can be found in the possible
field of log_request_evaluation
:
1{"log_request_evaluation":{"possible":true,"max_possible_day_quantity":122049}}
The report request is created with the logrequests
method. Here's how it looks:
1<https://api-metrika.yandex.net/management/v1/counter/{counterId}/logrequests>2 ? [date1=<string>]3 & [date2=<string>]4 & [fields=<string>]5 & [source=<log_request_source>]
The GET request parameters for the logrequests
method are just as in evaluate
:
date1
— the start date for statistics collectiondate2
— the end date (can't be the current date)fields
— a list of fields separated by commassource
— log source
The response page contains data in JSON format. The main information can be found in the request_id
field of log_request.
This is the logs request identifier. You'll use this to see if the data is ready:
1{'log_request': {'request_id': 4518541,2 'counter_id': 44147844,3 'source': 'visits',4 'date1': '2019-04-01',5 'date2': '2019-05-31',6 'fields': ['ym:s:visitID',7 'ym:s:dateTime',8 'ym:s:isNewUser',9 'ym:s:visitDuration',10 'ym:s:startURL',11 'ym:s:clientID',12 'ym:s:lastTrafficSource'],13 'status': 'created'}}
To get information on the status requests processed by Yandex.Metrica, we'll need to use the logrequests
method.
1<https://api-metrika.yandex.net/management/v1/counter/{counterId}/logrequest/{request_id}>
The following parameters are passed in the URL:
counterId
— counter identifierrequest_id
— logs request identifier.
Here's how we check to see if logs are ready:
1import time2status = 'created'3while status == 'created':4 time.sleep(60)5 print ('trying')6 r = requests.get(URL,headers={'Authorization': 'OAuth {0}'.format(TOKEN)})7 if r.status_code == 200:8 status = json.loads(r.text)['log_request']['status']9 print (json.dumps(json.loads(r.text)['log_request'], indent = 4))
If there's a lot of data, the Yandex.Metrica API returns it in parts. The response with the status "processed"
stores the list of all data parts in parts
.
To get a portion of the data from logs you'll need to send the following GET request:
1<https://api-metrika.yandex.net/management/v1/counter/{counterId}/logrequest/{request_id}/part/{part}/download>
The following parameters are passed in the URL:
counterId
— counter identifierrequest_id
— logs request identifierpart
— number of parts
The StringIO()
function from the io
library allows a string to be read as a file. The thing is that the read_csv()
method takes only files as its argument, while the portion of data in the API response is returned as a string. StringIO(r.text)
converts the string into a memory file. This makes it possible to read it with the read_csv()
method in the DataFrame tmp_df
.
1tmp_df = pd.read_csv(StringIO(r.text), sep = '\t')