X
X
xonar2019-12-27 14:15:42
JavaScript
xonar, 2019-12-27 14:15:42

How to make sending data work?

Hello. All with the upcoming!
Please help. For solving the problem with me for a beer is guaranteed!
You need to force the script to collect data and send it to CRM.
There is documentation - https://help.retailcrm.ru/Developers/Collector#examples
I need to attach a handler to my landing page so that the data is sent when the order is placed.
From the documentation I understand that you need to connect:

<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'); // это ключ от CRM аккаунта
    _rc('send', 'pageView');
</script>

Next comes the script for sending data from 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(),
        });
        return false;
    })
})
</script>

My form has input values ​​like this:
<form class="form-element" action="/mod/lead/send/" method="post" enctype="multipart/form-data" novalidate=""

<input type="text" class="form-field-text--input" name="form[273045]" autocomplete="on" data-check="name" data-required="true" required="">

<input type="tel" class="form-field-text--input" name="form[666702]" autocomplete="on" data-check="phone" data-mask="phone" data-required="true" required="">

Naturally, I change the form class, the input classes that need to be tracked:
$('#form-element').submit(function() {
        _rc('send', 'order', {
            'name': $(this).find('input[form[273045]]').val(),
            'email': $(this).find('input[form[666702]]').val(),
        });

As a result, nothing comes to the CRM system. I even looked on YouTube, I'm doing the same thing, but I can't figure out where the mistake is.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
srjk94, 2019-12-27
@xonar

Try these selectors input[name="form[273045]"] and input[name="form[666702]"]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question