Let's continue our discussion about working with user parameters. Last time we went into detail about how to transmit data online and in this article we will talk about uploading it offline. This method lets you add information that you already have in your database (such as customer income or loyalty status) to your reports.
In order for Metrica to determine which visitor should have these new attributes, data from your base needs to be linked to Metrica data by assigning them the same ID. This can be done either by sending Metrica your own customer IDs (UserID) or by entering unique visitor numbers from Metrica (ClientID) into your CRM.
Stage 1. Teach Metrica to recognize customers
To start transmitting your own authorized user IDs (UserID) to Metrica, you need to add code on your site that will insert these IDs into the setUserID method:
UserIDs will not display in reports; they are saved in the Metrica database as keys that allow Metrica visitors and your CRM customers to be matched. Every time an authorized visitor visits your site, Metrica receives a command to "remember" that visitor using their UserID.
This match will be made for all your registered visitors after they visit your site at least once under their username. This process may take some time: it depends on how often your customers return to your site.
☞ UserID can be sent for non-authorized visitors as well. You can also get unique IDs from "tagged" links that you send to your customers via email or social network referrers. Discount card numbers or promo codes that the visitor enters on your site can also be used as UserIDs.
Stage 2. Upload data
After sending Metrica enough UserIDs, you will need to prepare a file with the customer attributes that you want to add to your reports. This table should be in csv format with three columns. The first contains UserIDs, which will be used as keys to link data in your file to Metrica data. The second will contain parameter names and the third is for parameter values.
Here is how that type of file looks:
To send this file to Metrica, go to the Upload Data tab in the counter settings. Don't forget to choose the file type — UserId:
After the file is processed, you will see this notification in the interface:
Status: Completed (80% match). This means that the UserIDs you transmitted were found in Metrica for 80% of the customers in your file. Usually the data can not by completely matched up because not all customers visited your site, which means that you haven't transmitted their UserIDs yet, and Metrica doesn't know which visitors it should assign the attributes in your table to. So parameters will only be added for the 80% of visitors that were matched. It's important to keep this in mind when you look at your report data.
☞ Metrica can store up to 1000 parameters for a single visitor.
Matching by ClientID when you don't have your own visitor IDs
A ClientID is a number that Metrica assigns to every visitor. It can be used as a key to link data if your site doesn't have its own identification system or if customers rarely register online (because, for example, they place orders by phone).
To get ClientIDs from Metrica, add code that calls the getClientID method to your site and record the value you get to your CRM:
<ClientID> = yaCounterXXXXXX.getClientID()
After some time has passed and enough visitors have been to your site and gotten ClientIDs, a csv table of customer attributes can be generated. It will look the same as in the UserID example, only this time the first column will use ClientIDs as keys that match visitors. And you need to choose the ClientID file type when you upload a table to Metrica.
How to update or delete uploaded data
All you have to do for reports to start displaying new parameter values is upload a current file. If you want to delete data, you need to go to the same data-upload menu, select Delete and transmit a file with empty parameter values:
Uploading this type of file doesn't set parameter values to zero; it deletes them. In other words, if you transmitted the number of purchases per client and then uploaded an empty file, the offline-purchase parameter would just disappear from your reports rather than have a zero value.
Is it better to transmit visitor parameters online or offline?
With the userParams method, it makes sense to send data that only relates to online behavior and doesn't need to be stored in your own database. This way also works for internet publications or blogs that don't have CRMs.
The two approaches also differ by the speed of data updates in reports. When you get the setUserID or getClientID method up and running and the majority of your customers have visited your site at least once, new data will show up right away in reports as soon as you upload a current file (rather than waiting until the customer returns to your site.
You can find answers to frequently asked questions regarding both ways to work with visitor parameters in this article.