Daemon Collector
Copy the link to the article
Copied

Daemon Collector is a specialised system service that ensures close interaction between the system and users who are on your site. Collector is easily installed on the site using js-inserts and allows you to:

  • see in the system interface which of your customers is currently on the site

  • collect contact information of users at the time they leave the site

  • quickly connect the application and feedback forms of your site to the system

Initialization

Place this code just before the closing tag </head>

<script type="text/javascript">
        (function(_,r,e,t,a,i,l){_['retailCRMObject']=a;_[a]=_[a]||function(){(_[a].q=_[a].q||[]).push(arguments)};_[a].l=1*new Date();l=r.getElementsByTagName(e)[0];i=r.createElement(e);i.async=!0;i.src=t;l.parentNode.insertBefore(i,l)})(window,document,'script','https://collector.simla.com/w.js','_rc');

        _rc('create', 'site-key', {
                customer: {
                        externalId: 'Customer-ID-on-site  (customer.externalId в crm)'
                }
        });

        _rc('send', 'pageView');
</script>

In the call _rc('create'..., the context is initialized. A mandatory parameter for this call is the site key site-key, which is generated when activating the site in the system section "Administration > Integration > Collector".

If the user is authorized on the site, it is necessary to pass the external identifier of the user in the customer.externalId key (the external identifier of the customer must be used as the value). If the user is not authorized, then the key customer.externalId does not need to be specified.

You can also set the current customer identifier (customer.externalId) using the following method:

_rc('use', 'customer', { externalId: 'customer-ID-on-site (customer.externalId в crm)' })

This method will be useful, for example, for SPA sites (single page application), when Collector is already embedded on the site. A site visitor enters without logging in - Collector is connected (initialization takes place), but when calling the create method, the customer identifier is not transferred. In this case, this method solves this problem, transferring the customer id, for example, immediately after the customer logs in to the site.

Below you can find examples of meter installation.

It is also possible to track the client's online status on the site. Tracking is possible both using the capture form for customers who placed an order through it, and by the clientId tag, if there is an integration with Google Analytics on the site and a configured CRM and GA integration module.

In addition to the indicator, there is a filter by the "Online" status in the list of customers.

Collector tries to identify the customer who came to the site using any of the following parameters:

  • Customer ID on the site customer.externalId '(if specified)'

  • Tag _ga of Google Analytics

  • Own label of Collector

Connecting a capture form

The capture form determines that the user is going to leave the site and invites him to leave his contact information to receive special offers, news, etc.

The form is a plug-in, to load the module, use the require command.

_rc('require', 'capture-form');

By default, the form will be shown to the user once, regardless of whether he eventually left contacts or just closed the form. In the period parameter, you can set (in minutes) when the form will be shown to the user again:

_rc('require', 'capture-form', {
        'period': 60 * 24 * 30 // show in one month
});

Important!

The form will not be shown to the user authorized on the site, that is, if in the call code _rc('create'... is specified in the customerId parameter.

By default, the form displays the fields "Name" name, "Phone" phone, "Email" email. You can configure the composition of the fields:

_rc('require', 'capture-form', {
        'fields': {
                'name': {},
                'phone': { required: true, label: 'Phone' } // the phone is required
        }
});

You can also redefine the introductory text and text on the button:

_rc('require', 'capture-form', {
        'fields': {
                'phone': { required: true }
        },
        labelPromo: "Do you want us to call you back?",
        labelSend: "Call me back!"
});

When initializing or opening a form, you can set the following parameters:

name Name email Email phone Phone customerComment User comment orderType Order type orderMethod Order method itemId Product ID on the site customSomeField Custom fields

Values ​​for custom fields are specified with the prefix custom followed by the code of the custom field in camelСase. For example, the custom field bonus_code must be specified as customBonusCode.

_rc('require', 'capture-form', {
        orderMethod: 'online',
        email: "user@example.net",
        customTransactionId: "acde1625ab7"
});

You can manually trigger the form display:

_rc('capture-form:show', {
    'fields': ['phone']
});

Using a custom capture form

You can completely replace the form that will be used to interact with the user, for this you need to pass the form parameter during initialization:

_rc('require', 'capture-form', {
        form: {
                show: function () {
                        // the code that will show the form to the user, for example:
                        // $('#my-cool-form').show();
                },
                hide: function () {
                        // the code that will close the form, for example: 
                        // $('#my-cool-form').hide();
                }
     }
});

You also need to implement sending data by yourself.

Submitting an application

Daemon Collector allows to send requests from your site to the system without having to interact with the full API of the system. Sending is done by calling _rc('send', 'order', {...}).

_rc('send', 'order', {
        'name': 'Victor',
        'email': 'some-email@mail.ru'
});

When submitting, you can specify the same parameters as for the capture form.

Below is an example of sending a feedback form to the system.

Examples

Example of the code for initializing tracking on the landing page

This is how the tracking code will look when installed on sites without a user base, for example, on a landing page.

<script type="text/javascript">
        (function(_,r,e,t,a,i,l){_['retailCRMObject']=a;_[a]=_[a]||function(){(_[a].q=_[a].q||[]).push(arguments)};_[a].l=1*new Date();l=r.getElementsByTagName(e)[0];i=r.createElement(e);i.async=!0;i.src=t;l.parentNode.insertBefore(i,l)})(window,document,'script','https://collector.retailcrm.pro/w.js','_rc');

        _rc('create', 'RC-16632969589');
        _rc('send', 'pageView');
</script>

Example of the php template code to initialize tracking

The tracking code will be similar to this example for sites with a user base, for example, when installed on the pages of an online store.

<script type="text/javascript">
        (function(_,r,e,t,a,i,l){_['retailCRMObject']=a;_[a]=_[a]||function(){(_[a].q=_[a].q||[]).push(arguments)};_[a].l=1*new Date();l=r.getElementsByTagName(e)[0];i=r.createElement(e);i.async=!0;i.src=t;l.parentNode.insertBefore(i,l)})(window,document,'script','https://collector.retailcrm.pro/w.js','_rc');

<?php
        $params = array();
        if ($customer->isAuth()) {
                $params['customer'] = [
                        'externalId' => $customer->getId(),
                ];
        }

        echo sprintf("_rc('create', 'RC-16632969589', %s);\n", json_encode((object) $params));
?>

        _rc('send', 'pageView');
</script>

An example of sending an application to the system via js api

Let's say there is a landing page with an application form that is connected to the CPA network. We need to submit a form to the system with the transaction ID of the CPA network in the custom field transaction_id.

1) We create the custom field transaction_id.

2) We include jQuery for the convenience of working with the application form and the jQuery plugin for getting URL parameters:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script type="text/javascript" src="/jquery.url.js"></script>

3) Add the Collector tracking code:

<script type="text/javascript">
        (function(_,r,e,t,a,i,l){_['retailCRMObject']=a;_[a]=_[a]||function(){(_[a].q=_[a].q||[]).push(arguments)};_[a].l=1*new Date();l=r.getElementsByTagName(e)[0];i=r.createElement(e);i.async=!0;i.src=t;l.parentNode.insertBefore(i,l)})(window,document,'script','https://collector.retailcrm.pro/w.js','_rc');

        _rc('create', 'RC-16632969589');
        _rc('send', 'pageView');
</script>

4) Set up the form submission. When sending an application, we specify for it the order method "Feedback form" feedback. After submitting, we notify the user about the result of submitting the form.

<script type="text/javascript">
$(function() {
        $('#feedback-form').submit(function() {
                _rc('send', 'order', {
                        'name': $(this).find('input[name=name]').val(),
                        'email': $(this).find('input[name=email]').val(),
                        'customTransactionId': url('?transaction_id'),
                        'orderMethod': 'feedback',
                        'callback': function(success, response) {
                                // we notify the user about the result of sending the form
                                // instead of alert(), a more user-friendly message can be displayed
                                if (success) {
                                        alert('Thanks, your request has been accepted. Its number: ' + response.id); 
                                } else {
                                        alert('Unfortunately, the request hasn't been sent.');
                                }
                        }
                });

                return false;
        })
})
</script>

What is response.id in Demon Collector?

response.id in Demon Collector is externalId of the order in RetailCRM.

Thank you for your feedback.
Was this article helpful?
No
  • Рекомендации не помогли
  • Нет ответа на мой вопрос
  • Текст трудно понять
  • Не нравится описанный функционал
Yes
Next article
Uploading a catalog to the system via ICML
The ICML format is an extension of the YML format that allows to upload technical information about products to the system, as well as a complex structure of catalogs with trade offers. In the article, we will analyze the elements used and the peculiarities of the catalog formation.
#}