Skip to content

Integration with Pipedrive

How It Works

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 tracking 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 deal export from Roistat to Pipedrive by adding the value of the roistat_visit cookie to the deal. We developed an easy-to-manage module for data export. It won't take you a lot to set it up.

In summary, when a visitor completes the target action on the web page, 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, a manager asks him/her for a promotional code and puts it down to a deal card.

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 place more than one counter in a page to prevent inaccurate data entry.

Step 2. Add Roistat Field in Pipedrive

It's necessary to add the roistat field to Pipedrive deal detail view.

  1. Open Settings → Customize fields → Add a field:


    • Select the field type: Text

    • Name the field: roistat

    Click Save to add the custom field:


  2. After the roistat field appeared in the fields list, click on the value of the corresponding Show in add new dialog cell to activate the option. It will be then set Yes:


Step 3. Arrange Statuses

Navigate to Settings → Integrations and choose Pipedrive from the integrations list. Click Select to save the integration type.

Specify the Pipedrive API token in the API token field. You can copy it from your Pipedrive account: Settings → Personal → API.


Specify the roistat field API key in the Field API key field. You can copy it from your Pipedrive account: Settings → Customize fields. Click the roistat field name.


Once you have specified all the information needed and saved it by clicking Save, Pipedrive deal statuses will be imported to Roistat.

Please note:

The two statuses Won and Lost should be classified as Paid deals and Rejected deals correspondingly.


Step 4. Automatic Deals Export

If deals are already created automatically

In this case, the roistat field 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"

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

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

To set up deal proxying, insert the following code snippet into the file that process deal forms on your website (e.g. send 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 -> Pipedrive
 'title'   => 'Lead title',
 'comment' => 'Lead commentary',
 'name' => 'Client's name',
 'email'   => '',
 'phone'   => '79111234567',
 'fields'  => array(

file_get_contents("" . http_build_query($roistatData));

Verify the Integration

When a client completes some target action (completes application form, places an order etc.), a new deal is created in Pipedrive and characterized among others by the roistat field. The field must be non-empty.

You can view deals from Roistat as well going to the Project diagnosticsList of submitted leads section: