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

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

How it works


Roistat will import both deals from the Deals and Leads pages in Bitrix24 if you set up the Bitrix24 (leads + deals) type of integration. If you need Roistat to import data only from the Deals page, read Bitrix24 (deals).

The tracking code serves to collect and send visitors' data to Roistat from a website.

Firstly, the tracking code should be placed on each web page you wish to track. Having added the code will set the roistat_visit variable containing a visit ID into the cookie. Once you have successfully installed the tracking code on your website, the Promo Code functionality will be available. 

Secondly, it's necessary to customize lead export from Roistat to Bitrix24 by adding the value of the roistat_visit cookie to the deal. We developed an easy-to-manage module to export leads. It won't take you a lot to set it up.

In summary, when a visitor creates some request on your website, a new deal is created in your CRM and characterized among others by the visit ID (the roistat_visit variable) contained in the roistat field. Otherwise, if a client is calling to make an order, a manager may ask him/her for a promotional code and put it down into the custom field on a deal card; promo code appearance needs special setup.

Step 1. Set up tracking code

To view the Roistat tracking code, navigate to Settings  Tracking Code:

Insert the code between the <body></body> tag of your web pages. It can be placed next to the Google Analytics counter or any others.

The tracking code must be placed into the HTML code of every page of your website.

Consequently, all visits will be counted and analyzed in Analytics.

Do not insert more than one counter in a page to prevent inaccurate data entry.

Step 2. Add roistat field in Bitrix24

Bitrix24 deals/leads should be characterized among others by visitor IDs in order to be linked to visits. This requires the roistat field to be added to Bitrix24 entities Lead and Deal.

To do this, in your Bitrix24 account navigate to CRM  Settings  Form and report settings  Custom fields  Deal/Lead and click Add field:

Create the following field:

  • Name: roistat;

  • Type: string:

Step 3. Configure Roistat access to Bitrix24

To integrate with Roistat, it's necessary to install our application.


Mind that only a user with administrator rights can install applications in Bitrix24.

In Roistat, open Settings  Integrations and choose Bitrix24 (leads + deals) from the Available integrations drop-down menu. Click Select to save the integration type.

Enter your Bitrix24 project URL into the corresponding field (the URL usually looks like http://<project>.bitrix24.com) and click Application install:

The installation window will then open in your Bitrix24 account. Click the Install button:

In Roistat, click the Sign in button to save your Bitrix24 authorization settings:

Once the sign-in settings has been saved, integration advanced settings will be displayed:





Revenue field

You may specify any Bitrix24 field that corresponds to the Roistat revenue field, if necessary.

To do this, select a field name from the drop-down menu.

  • Not used: the amount of revenue is exported from the standard Bitrix24 field "Amount/Currency" to Roistat;

  • The name of a custom field in Bitrix24: the amount of revenue is exported from the custom Bitrix24 field to Roistat.

First cost field

You may specify any Bitrix24 field that corresponds to the Roistat first cost and profit fields, if necessary.

To do this, select a field name from the drop-down menu.

  • Not used: the amount of first cost/profit is automatically calculated by Roistat;

  • The name of a custom field in Bitrix24: the amount of first cost/profit is imported from the custom Bitrix24 field to Roistat.

Profit field

Responsible for deals

You may specify any responsible managers to import only their deals to Roistat, if necessary.

Managers' IDs separated by comma

Filtration field

The type of a filter.

By default, all deals and leads are exported from your Bitrix24 account.

You may configure what specific fields should be exported from Bitrix24, if necessary. To do this, select a field name from the drop-down menu.

  • Filtration off: all deals and leads are exported  from Bitrix24 to Roistat;

  • The name of a field in Bitrix24: deals and leads in Bitrix24 are filtered by this field and then exported to Roistat (the Filtration value field must be specified).

Filtration value

The value of a filter which is applied to select specific deals and leads to be exported from Bitrix24 to Roistat.

It must be specified if filtration is on.

The value of a filtration field.

Use regular expressions if you understand them.


Once you have specified all the information needed and saved it by clicking Save, Bitrix24 statuses will be imported to Roistat. You should correlate them with the Roistat statuses.

Step 4. Arrange statuses

Once Bitrix24 has integrated with Roistat, you'll need to arrange deals and leads statuses:

  • Not registered: waste leads or duplicate deals. Do not delete such deals to provide reliable statistics. You can gather them all in one status, e.g. Waste;

  • Processing: deals being in process, not completed, e.g. negotiations or product packaging;

  • Paid: deals that are paid or very likely to be paid;

  • Rejected: when a client rejects the purchase or requests a refund.

Just drag and drop a status to the box you wish.


Quote statuses will be imported to Roistat as well. It's a Bitrix24 API shortcoming, so that you should leave these statuses in the Not registered group.

Moreover, you should leave the Converted status in the Not registered group otherwise leads and deals converted from those leads will overlap.

All the statuses can be distributed the following way:

Step 5. Automatic leads export

 If deals are already created automatically

In this case, the commentary field of a lead should contain the value of the roistat_visit cookie.

Below is an example of the string that contains the value of this cookie:

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

The string to insert into the lead commentary field should have the format as follows:

roistat: {$roistatVisitId}

When created leads should be automatically exported from your website to Bitrix24. For this to happen, we offer you a complete solution: deal proxying.

When a visitor creates some request on your website, a new deal is automatically created in Bitrix24 as well, and a backup copy of the lead data is stored in your Roistat account. Keeping this in mind, you will not have to worry that Bitrix24 can be off-line sometimes. In any case, all the data is stored and then re-exported to Bitrix24 some time later.

To set up deal proxying, insert the following code snippet into the file that processes deal forms on your website (e.g. sends data to some e-mail):

// Data should be encoded in UTF-8
// If Windows-1251 is used, you can convert all variables through $value = iconv("Windows-1251", "UTF-8", $value);
// ...
// the current lead creation function, e.g. mail(), is called somewhere here
// ...
$roistatData = array(
    'roistat' => isset($_COOKIE['roistat_visit']) ? $_COOKIE['roistat_visit'] : null,
    'key'     => 'SECRET_KEY', // Instead of SECRET KEY insert the secret key itself which you can copy by clicking the Integration key: show link at the bottom of the page Settings -> Integrations -> Bitrix24(leads + deals)
    'title'   => 'Lead title',
    'comment' => 'Lead commentary',
    'name'    => 'Client's name',
    'email'   => 'client@email.com',
    'phone'   => '79111234567',
    'fields'  => array(
    // An  array with some additional fields if needed or just an empty array
    // Examples:
        "OPPORTUNITY" => 123, // The Amount field (Deals) in Bitrix24
		"ASSIGNED_BY_ID" => 3, // A person responsible for the lead
		"UF_CRM_1425989455" => "Текст", // A custom field with the ID UF_CRM_1425989455
		"SOURCE_ID" => 47, // The Source field
		"SOURCE_DESCRIPTION" => 25 // The More about the source field
    //  For more detailed information about field names and custom fields list please read the Bitrix24 Rest API available in your Bitrix24 account.
    // You can consult our support service about Bitrix24 custom fields as well.
file_get_contents("https://cloud.roistat.com/api/proxy/1.0/leads/add?" . http_build_query($roistatData));

Verify the integration

When a client creates some request on your website, a new lead will be created in Bitrix24 and will have a commentary with the roistat code.

You can view deals from Roistat as well by clicking the corresponding link:

  • No labels