Online stores often need

5/5 - (1 vote)

Measurement Protocol (hereinafter MP) is a tool that allows you to transfer user interaction data directly from your server to Metrica servers via HTTP requests. It expands the capabilities of data collection and analysis: it supplements the data collected by the standard Online stores often need  web counter.

With MP you can send:

  • page visits;
  • execution of JavaScript targets;
  • e-commerce events (product views, purchases, cart additions and deletions).

In this article, we looked at scenarios where MP can be useful and provided examples of Python code for sending data to Yandex Metrica. 

 Scenarios using MP Online stores often need 

Based on many years of experience working with Yandex Metrica, we have identified 2 main scenarios in which we cannot do without a new tool (Measurement Protocol):

  • Tracking interactions with the chatbot;
  • Transmission of transactions in the field of e-commerce.

1. Interacting with the chatbot Online stores often need 

Previously, Yandex Metrica did not have the ability to fully track user interactions with a chatbot (Telegram, VK, etc.). It was possible to track through offline conversions, but this method is inconvenient and unreliable.

Therefore, the chatbot tracked key/final steps or used another tool, for example, Google Analytics 4. For companies that need to use domestic tools, this became a problem. 

With the advent of MP in Yandex Metrica, it became possible to track any user interaction with the chatbot, simulating the sending of page views with screen names, for example:

  • https://yourdomain.ru/chatbot/main_screen (chatbot main screen)

2. Transactions in e-commerce Online stores often need 

Online stores often need to send information about a new caledonia business email list purchase from the server if the site has the option of online payment with a transition to the acquiring page. This is due to the fact that some users immediately close the site after payment, and the transaction information does not have time to go to Yandex Metrica. 

There may also be other scenarios where the number of actual transactions does not match the number of transactions in Yandex Metrica. In such cases, it is more reliable to send data from the server. 

The MP tool allows you to send all transactions from the server. Therefore, the number of transactions will fully correspond to the actual number of orders in the CRM.

Examples of sending data to Yandex Metrica servers

How to get a token Online stores often need 

Before sending data to Yandex Metrica, you need to get a token. 

To do this, go to: “Settings > Counter > Additional sending out a quality settings > Security and data usage > Measurement Protocol”.

 

 

The maximum number of active tokens per counter is 5. 

Submitting a page view

Code template for sending pageview information:

  • #Submit page view
  • import requests
  • import json
  • import pandas as pd
  • import pandasql as ps
  • #—————–To fill (beginning)
  • ms = ” #Please enter your token
  • tid = 88989734 #Specify your counter
  • cid = 1710232430899999999 #ClientID identifier
  • dr = ‘https://yandex.ru/’ #Referer
  • dl = ‘https://yourdomain.ru/chatbot/main_screen’         #URL
  • dt = ‘Chatbot Main Screen’ #Page Title
  • #et = 1728630000 #Hit time (Timestamp, if not passed, the time of data reception will be used)
  • #—————–To fill (end)
  • URL=’https://mc.yandex.ru/collect/?tid=’+str(tid)+’&cid=’+str(cid)+’&t=pageview&dr=’+str(dr)+’&dl=’+str(dl)+’&dt=’+str(dt)+’&ms=’+str(ms)
  • r_s = requests.get(URL)
  • print(r_s)

You need to substitute your token (ms) into the code and specify the counter number (tid).

Key parameters:

  • cid — ClientID identifier,
  • dl — URL,
  • dt — page title.

ClientID is a parameter that Yandex Metrica uses to b2c fax understand who the hits belong to. If the hits are sent from a chatbot, you can generate your own ClientID, provided that you do not need to combine user data from the site and the chatbot. 

Leave a Comment

Your email address will not be published. Required fields are marked *