Page tree
Skip to end of metadata
Go to start of metadata

Why do you need to upload the leads to Roistat

The leads must be uploaded to Roistat to use the information about them in Analytics.

There are two methods of uploading the leads to Roistat:

The first method of uploading the leads to Roistat

The first method is used when the sending of leads to Roistat is already configured. In this way, the leads are uploaded to Roistat after the integration with CRM. This method of configuration is easy: you only have to create an additional field in CRM and add the script that automatically fills in this field with a unique visit number.

(отметить) Use this method if the automatic sending of leads from the website to CRM is already configured and you don't want to make any changes. 

The second method of uploading the leads to Roistat

While using the second method, leads from the website are firstly sent to Roistat and then are sent to CRM. 

This method of upload the leads to Roistat is more reliable than the first one. If CRM was unavailable during the creation of the lead, the lead will not be lost. It will be created in CRM when the CRM is available. Roistat will attempt to send the lead every 30 minutes for the next 48 hours.

In this way, you have to find and change the script that sends the data.

(отметить) Use this method if the leads from the website are sent to email, and your managers create this leads in CRM manually.

(информация) Roistat refreshes the data about the leads that were changed in CRM at regular intervals. The date of creation of these leads does not matter. 

You can see the frequency of refreshing the information about the leads on the Project status page.

By default, Roistat requests from CRM the data on the leads that were changed during the last 7 days. If you had no access to your CRM for more than 7 days, contact our customer service.

How to configure the upload of leads from CRM

Create an additional field

When a client visits your website, the information about the visit is saved in your browser. To bind the visits to the leads in CRM, Roistat utilizes the visit number. Visit number is the unique number of the visit that is written in the  roistat_visit cookie. The containment of this cookie must be transmitted to CRM with the created lead. To do it, you must create additional field Roistat in CRM.

Configuring the script

Add the script that receives the value of roistat_visit cookie to your website before sending the data to CRM.

Example of the script:

$roistatVisitId = array_key_exists('roistat_visit', $_COOKIE) ? $_COOKIE['roistat_visit'] : 'nocookie'

How to configure the sending of leads to CRM 

Create an additional field

Create an additional field named roistat, that will contain the visit number.

Configuring the script

1. Open your website server and find a file that processes the form of the lead. For example, this file may be a script that sends the data from the form to to e-mail. 

2. The data in this file must be in UTF-8 encoding.

3. Add the Roistat script to this file. The script will collect the data from the lead and send it to Roistat. On the basis of this data, Roistat will create a lead in CRM.

Example of the script:

$roistatData = array(
    'roistat' => isset($_COOKIE['roistat_visit']) ? $_COOKIE['roistat_visit'] : 'nocookie',
    'key'     => 'value', //value is the integration key from your Roistat project
    'phone'   => 'value', //value is the client's phone number or variable that receives this number
	'email'   => 'value', //value is the client's email or variable that receives this email
    'fields'  => array(), //array that can be filled to receive the values of additional fields or can be left empty
file_get_contents("https://cloud.roistat.com/api/proxy/1.0/leads/add?" . http_build_query($roistatData));

(warning) Client's phone number and email are mandatory fields. You have to transmit at least one of them, or lead will not be created.

Integration key must also be entered. Without integration key, the upload of leads will not work. You can find the integration key in your Integration catalog:

Additional settings

These settings are useful, but not necessary. If you want only to transmit the standard fields of the lead to CRM and dont need to configure the callback and verification of incoming leads for duplicate, go to configuration testing phase. 


If a client left his phone number in the form of the lead, you can automatically call him back. To do it, you need to activate the callback in the Lead Hunter settings and specify your manager's phone number for callback.

Transmission of additional fields

You can create the additional fields of leads in your CRM and automatically fill them using the Roistat service when a lead is created using the website form. For example, you can appoint a responsible manager by transmitting his ID to the field in CRM. 

The formats and names of additional fields in each CRM are different. To transmit their value, you have to know their ID. If you don't know the ID of these fields, contact your CRM customer service. 

Many CRM's have API. With the help of API-method, you can upload your leads and check out their fields and ID of these fields. 

The usage of variables

You can use the variables to transmit the value of the visit to some fields of the lead. For example, you can transmit the name of the city to the additional field in CRM from which the client visited your website and made a lead.

You can use the variables in the following fields of the leads: 

  • title
  • comment
  • name
  • additional fields
 Which variables you can use



{city}City name
{visit}Visit number
{referrer}Referrer page
{landingPage}Landing page
{source}Source (marker)
{utmSource}utm_source tag value
{utmMedium}utm_medium tag value
{utmCampaign}utm_campaign tag value
{utmTerm}utm_term tag value
{utmContent}utm_content tag value
{callee}dialed number


roistat_param1 tag value
{roistatParam2}roistat_param2 tag value
{roistatParam3}roistat_param3 tag value
{roistatParam4}roistat_param4 tag value
{roistatParam5}roistat_param5 tag value
 Example of using the variables
$roistatData = array( 
	'title' => 'New deal {visit}', //Add the visit number to the title of the deal
	'name' => 'Client's name {visit}', //Add the visit number to the client's name
	'comment' => 'utm_source: {utmSource}, utm_medium: {utmMedium}, utm_campaign: {utmCampaign}', //Transmit the utm-tags to the comment of the deal 
	'fields' => array( 
		'1276733' => '{city}', // Save the city of the visitor in the additional field 1276733
		'tags' => 'Тег1, {utmSource}, {utmMedium}, {utmCampaign}', // Save the values of utm-tags in tags
file_get_contents("https://cloud.roistat.com/api/proxy/1.0/leads/add?" . http_build_query($roistatData));

Verification of incoming requests for duplicates

Approval of deal creation in CRM

Use the 'sync' => '1'  parameter when after the sending of lead from website to Roistat you need to receive the approval of deal creation from CRM. If the deal is created successfully, the script will return its ID. It may be useful to show a client the number of order after the creation of the deal. If the deal cannot be created, you will see the error message instead of ID. 

 Example of using
$roistatData = array(
    'roistat' => isset($_COOKIE['roistat_visit']) ? $_COOKIE['roistat_visit'] : 'nocookie',
	'key'     => 'SECRET_KEY'
    'title'   => 'Title of the deal',
    'name'    => 'Client's',
    'phone'   => '11231234567',
	'sync' => '1',

Performance testing

Create the lead from the website. If everything is configured well:

  • the new deal will appear in Sent leads;
  • the number of the visit will appear in the в Promo code field; 
  • the successful status of lead will appear in the Sent field ();
  • the new lead will appear in CRM.

(информация) You can export the list of the lead to Excel. To do it, select the period and click the Download button:

Solution to the problems

 Lead from the website does not exist in Sent leads

It means that the lead is not sent from the website to Roistat or cannot be received by Roistat. Possible causes: 

  1. Problems with your website server.
  2. Error in the script. 

How to solve:

  1. Change the last line of the script from this:
    file_get_contents("https://cloud.roistat.com/api/proxy/1.0/leads/add?" . http_build_query($roistatData));

    to this:

    file_get_contents("http://cloud-reserved.roistat.com/api/proxy/1.0/leads/add?" . http_build_query($roistatData));

    Save the changes and try to create the lead on the website once again. If it does not appear in the Sent leads, ask your provider why the data is not sent to the following addresses: https://cloud.roistat.com/api/proxy/1.0/leads/add;

  2. Check out the script for errors with the help of code checker

 Lead from the website exists in Sent leads, but does not exist in CRM

If the lead is not sent to CRM, it has the  status. Possible causes:

  1. Integration with CRM is not configured or it has you don't have the access to CRM.
  2. You do not have enough rights to create deals in CRM.
  3. CRM does not have mandatory fields that are filled while sending the lead. 

What to do:

  1. Check out if the data is specified correctly in the integrations settings page. 
  2. Check out if your CRM account has rights to create deals.
    1. If CRM has mandatory fields that must be transmitted in the script, make these fields optional. 
    2. If these fields must always be filled, add them to script and set them the value. 

(информация) If something does not work, contact our customer service.

  • No labels