(warning) The integration of Roistat with YCLIENTS works with records and contacts.

Step 1. Install the Roistat tracking code

Install the Roistat tracking code on every page of your website that is visited by your customers. The tracking code is needed to receive information about the visits. To learn more about the tracking code installation, read this article.

Change the code of the YCLIENTS form

Find the following code of YCLIENTS:

<script type="text/javascript" src="https://wXXXXX.yclients.com/widgetJS" charset="UTF-8"></script>

where wXXXXX - is your form ID.

Change it to the following code:

<script>
window.roistatVisitCallback = function(visitId) {
document.cookie = 'yextrafield_roistat=' + visitId;
var script = document.createElement('script');
script.src = "https://wXXXXX.yclients.com/widgetJS";
document.getElementsByTagName('body')[0].appendChild(script);
};
</script>

Insert your form ID instead of wXXXXX.

Step 2. Add the additional field "roistat"

To add the additional field, login to YCLIENTS and open Analytics → Integration with Roistat.

(warning) The additional field should be named roistat, otherwise, the integration won't work.

(отметить) If you create a lead manually, you can fill in the "roistat" field with the data of the source of the lead. The information about the source of the lead will be displayed in Analytics. 

To bind the lead to the specified marketing channel, enter the following markers in the roistat field:

Step 3. Connect the YCLIENTS in the Integrations list

  1. Open the Integrations list.
  2. Select the YCLIENTS and click the Connect button. 
  3. Fill in the authorization fields of YCLIENTS:
    1. Enter the email address or telephone number of your account in the Login field. The number should be entered in the following format: 1xxxxxxxxxx.
      (warning) Make sure that this user is added in the configurations of the main net and has admin acces. 

      a. Determine the main network of the branch. To do it, open the interface of the branch and open Settings → Networks.  

      b. Go to the settings of the main network and open Settings → Users. Verify if the user is added to the network configuration and has the full access rights. 
      (warning) If you cannot select the network in the interface, contact the administrator of this network.

      b. Enter your account password in the Login field.  

  4. Click the Save button. Statuses of the deals from YCLIENTS will be loaded.
  5. Distribute the statuses of the deals by dragging them into the statuses groups.
  6. Click the Continue button. 
  7. Specify the parameters for the additional configuration:
        a. Specify the parameters of the filtration of deals.
        b. Specify the values of business indicators. 
        c. Click the Save button. 
  8. Enter the IDs of your managers in the Deals responsible managers field.

    1. Log in to your YCLIENTS account, open the Managers section and click on the name of the needed manager.  
    2. The ID of the manager is displayed in the address bar after the master_id=.

     Enter the ID of the company of your responsible managers in the Company of the responsible managers field. 
    To find out the ID of the company, open Browse → Report. You will see the ID of the company in the Branch ID field.

  9. Click the Save button.
  10. Go to YCLIENTS and open Online-record → Website → Script injection.
  11. Enter the following code into the HTML code field:

    <script>
    (function(w, d, s, h, id) {
       w.roistatProjectId = id; w.roistatHost = h;
       var p = d.location.protocol == "https:" ? "https://" : "http://";
       var u = /^.*roistat_visit=[^;]+(.*)?$/.test(d.cookie) ? "/dist/module.js" : "/api/site/1.0/"+id+"/init";
       var js = d.createElement(s); js.charset="UTF-8"; js.async = 1; js.src = p+h+u; var js2 = d.getElementsByTagName(s)[0]; js2.parentNode.insertBefore(js, js2);
    })(window, document, 'script', 'cloud.roistat.com', 'tracking code key');
    </script>
    <script>
       window.onRoistatModuleLoaded = function () {
           var params = window
           .location
           .search
           .replace('?','')
           .split('&')
           .reduce(
               function(p,e){
                   var a = e.split('=');
                   p[ decodeURIComponent(a[0])] = decodeURIComponent(a[1]);
                   return p;
               },
               {}
           );
           if (params['yextrafield_roistat']) {
               window.roistat.setVisit(params['yextrafield_roistat']);
           }
       };
    
    window.roistatVisitCallback = function (visitId) {
          console.log('visitId', visitId);
            
    window.yclientsAdditionalOptions = {
                bookingCustomFields: {
                    roistat: visitId
                }
            };
        };
    </script>
    
    

    and enter the roistat tracking code key instead of 'tracking code field' using the ' ' brackets. 

  12. Click the Save button.

Step 4. Configure the automatic transfer of deals in YCLIENTS

If you use the third-party forms (besides of YCLIENTS widget), we recommend you to configure the transmission of leads to CRM via Roistat. Read more in this article.

If the transmission of deals from website to CRM is already configured with the help of your code, fill in the additional field "roistat" with the browser cookie roistat_visit

Here is the code you can use to receive the value of this cookie:

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

Verifying the performance

  1. Create the lead on the website.
  2. Open the Integration list in your project. 
  3. Find the YCLIENTS integration and click the Configure button. 
  4. Click the Sent leads button and find the lead you created.
  5. Check if the visit number is specified in the Promo code field.  
  6. Find the successful status of the lead () is in the Sent field.
  7. Find the new lead with the visit number in your CRM.