Skip to end of metadata
Go to start of metadata

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 it on your website, the Promo Code functionality will be available.

Secondly, it's necessary to customize deal export from Roistat to Custom CRM 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 creates some request on your website, a new deal is created 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 insert more than one counter in a page to prevent inaccurate data entry.


When the tracking code has been installed, it will be displayed for the users as a promo code on your website. It is used for call tracking.

To view and customize the style of the promo code form, click the Promocode appearance settings link or navigate to Calltracking Promo Code.

Refer to Promo Code documentation to learn how you can set up the promo code form.

Step 2. Add roistat field to your CRM

Every deal must be associated to a site visit. To do this, add the roistat field to your CRM deals.

Refer to any other integration guides to learn how to add the roistat field.

Step 3. Configure deals import from your site to a CRM

With Roistat you can send your deals directly to your CRM.

A new deal will be sent to your CRM with the roistat field value copied from the cookie field roistat_visit.

Refer to Integrate with CRM to learn how you can configure deals import to a CRM.

Verify the integration

When a client creates some request on your website, a new deal is created in a CRM and characterized among others by the roistat field. The field must be non-empty.

Step 4. Create a page to export deals

You should create a page that would export deals data in JSON format after having received the GET request with the parameters.

The Roistat server makes a GET request:

http://example.com/integration.php?date=1453836403&user=john&token=d41d8cd98f00b204e9800998ecf8427e&action=export

The GET request parameters are listed below:

ParameterDescription
dateThe date since which clients data will be exported (the UNIX-time format)
user

Username (specified in the integration settings)

tokenmd5 ( $username . $password )
actionAction type


Statuses and other deal parameters must be exported if changed: new status, new price or new values of additional fields.

 

The response formats:

  JSON format example
 XML format example

 

Types of array objects are not essential; usually they are str, int. The float type is often used for order price or first cost.

The statuses array contains the parameters of statuses for all orders (id, name).

The statuses array objects are listed below:

ObjectDescription
idStatus ID. Used in the orders array
nameHuman readable status name. Used in the Roistat interface


The orders array contains deals data updated within a specified time interval from date (a GET-parameter that we've sent) to the current date.

The orders array objects are listed below:

ObjectDescriptionRequired object
idStatus IDYes
nameHuman readable status name. Used in the Roistat interfaceNo
date_createDeal creation date in the format: UNIX-time or YYYY-MM-DD HH:MMYes
statusStatus ID from the statuses arrayYes
priceDeal price Used to calculate Revenue in RoistatNo
costDeal first cost Used for First cost in RoistatNo
roistat

Visit number that is associated to a deal. The value of the roistat_visit cookie. Used to trace

the deal source

No
client_idClient IDNo
fieldsOptional field that contains an array with additional deal fieldsNo


Below is an example of PHP code supposing it was exported from the database:

 Show

Step 5. Create a page to export clients

The same link which is used to export deals data can be applied to export clients’ data. The Roistat server makes the similar GET request, only the action=export_clients parameter is different:

http://example.com/integration.php?date=1453836403&user=john&token=d41d8cd98f00b204e9800998ecf8427e&action=export_clients

The GET request parameters are listed below:

ParameterDescription
dateThe date since which clients’ data will be exported (the UNIX-time format)
userUsername (specified in the integration settings)
tokenmd5 ( $username . $password )
actionAction type: export_clients


The response format:
 JSON format example
 XML format example


The clients array objects are listed below:

ObjectDescriptionRequired object
idClient IDYes
nameClient nameYes
phonePhone numberYes
emailE-mail addressYes
companyCompany nameNo
birth_dateDate of birth (in the Y-m-d format)No
fieldsOptional field that contains an array with extra deal fieldsNo

Step 6. Configure deals upload

Now, you should integrate Roistat with the page that store your CRM deals data.

To do this, open SettingsIntegrations and select Custom from the Available integrations drop-down menu.


Then specify access to your system:

Page URL: full URL used to upload deals from your CRM.

Login and Password: specify the login and password to access the upload page if needed.

If you fill in these fields, Roistat will add the token parameter when accessing the URL from the Page URL field, where $token = md5($user.$password);

Verify the integration

After you click the Save button, all deal statuses from the statuses array (see Step 4) will be displayed in the Status groups section.

Step 7. Arrange statuses

Once your CRM have integrated with Roistat, you'll need to arrange the statuses uploaded:

  • 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.

Do not import the status to Roistat in case you want it to be classified as Not registered.


Roistat will track your achievements (the Paid group) and forecast possible achievements (the Processing and Paid groups) basing on the grouping principle.

  • No labels