Examples of sending user parameters
Sending your own data in a CSV file
Consider the case of an online book store. In addition to order information such as total amounts and items sold, the website owner also has detailed information about customers: their age, whether they have children, and their children’s ages.
The site owner wants to analyze and use the information about children's ages. The site doesn’t use its own customer ID system.
Step 1. Prepare and send the data
-
Since the age information is stored in a database, we need to form a CSV file in order to send this data to Yandex Metrica.
-
Since you aren't using your own customer ID system, request the site user ID assigned by Yandex Metrica. To do this, use the getClientID method.
ym(XXXXXX, 'getClientID', function(clientID) { <function body> });You get a response:
"12345"where
XXXXXX— Counter number.12345is a string value.
-
Export the data you got and create a file with additional information about site users.

Then upload the file you prepared to Yandex Metrica and get your report.
The report shows that users have children ages 8–13. These are school-age children, so we can advertise school-related items before the beginning of the school year.
-
Step 2. Use the data in Yandex Metrica
-
To create a segment based on the sent user parameters in the Yandex Metrica interface:
-
Go to any report, for example, Sources, summary.
-
In the for people with condition group, click
. -
Select the condition: Characteristics -> User parameters.
-
Specify the parameter you need.
-
Sending data about user type (customer or partner)
In this case, you can differentiate users by whether they used the Customer sign in or Partner sign in link. Just like when you send data from your own database, you need to add special code to the page. This code will check the referrer (the link the user clicked to get to the login page) and send that information to the userParams method:
ym(XXXXXX, 'userParams', {
status: "client"
});
ym(XXXXXX, 'userParams', {
status: "partner"
});
where XXXXXX is your counter number.
Sending data from a field in a form
Site registration using a form
-
Let's say you have an online magazine for pet lovers. During registration, users can specify what kind of pet they have. In this case, we can get the data from the field on the form that users fill in:
ym(XXXXXX, 'userParams', {pet: "dog"});
Sending a request from a form
-
Let’s say that a food delivery company wants to analyze revenue from users in different parts of the city separately. We know that customers usually order deliveries to the same address, so the part of the city can be moved to the user level:
ym(XXXXXX, 'userParams', {delivery: "Arbat"});
|
Useful links |
Online training |