Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- document.addEventListener('mousedown', function(e) {
- if (e.target.matches('#getExempleModal form input.btn.btn-default')) {
- var form = getClosest(e.target, 'form'),
- name = form.querySelector('input[name="UNAME"]').value,
- email = form.querySelector('input[name="UEMAIL"]').value,
- company = form.querySelector('input[name="UCOMPANY"]').value,
- comment = form.querySelector('textarea[name="UMESSAGE"]').value,
- phone = form.querySelector('input[name="UPHONE"]').value,
- messageText = '\
- '+comment+'<br>\
- Имя: '+name+'<br>\
- Email: '+email+'<br>\
- Телефон: '+phone+'<br>\
- Компания: '+company+'',
- http = new XMLHttpRequest(),
- url = 'https://api.carrotquest.io/v1/users/' + carrotquest.data.user.id + '/startconversation',
- params = 'auth_token='+carrotquest.data.auth_token+'&body='+messageText;
- if (document.querySelector('.b-modal-form h4').innerHTML.indexOf('Цена') >-1 ||
- document.querySelector('.b-modal-form h4').innerHTML.indexOf('цену') >-1) {
- carrotquest.track('Заполнена форма "Узнать цену"');
- var productName = document.querySelector('.col-xs-6 h2').textContent.trim();
- var fileAttached = document.querySelectorAll('.b-file-input__item').length>0?', Файл: приложен. Проверять через почту':'';
- messageText = '\
- Хочу узнать цену на продукт. Продукт: '+productName+',<br>\
- Имя: '+name+',<br>\
- Email: '+email+',<br>\
- Телефон: '+phone+',<br>\
- Компания: '+company+',<br>\
- Сообщение: '+comment+' '+fileAttached,
- params = 'auth_token='+carrotquest.data.auth_token+'&body='+messageText;
- } else if (document.querySelector('.b-modal-form h4').innerHTML.indexOf('Получить на тестирование') >-1) {
- carrotquest.track('Заполнена форма "Получить образец"')
- } else if (document.querySelector('.b-modal-form h4').innerHTML.indexOf('Получить демонстрацию') >-1) {
- carrotquest.track('Заполнена форма "Получить демонстрацию"')
- }
- http.open('POST', url, true);
- http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
- http.send(params);
- carrotquest.identify([
- {op: 'update_or_create', key: '$name', value: name},
- {op: 'update_or_create', key: '$email', value: email},
- {op: 'update_or_create', key: 'Компания', value: company},
- {op: 'update_or_create', key: 'Сообщение из формы', value: comment},
- {op: 'update_or_create', key: '$phone', value: phone}
- ]);
- };
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement