Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //события для js поп-апов
- (function() {
- Element.prototype.remove = function() {
- this.parentElement.removeChild(this);
- };
- NodeList.prototype.remove = HTMLCollection.prototype.remove = function() {
- for (var i = this.length - 1; i >= 0; i--) {
- if (this[i] && this[i].parentElement) {
- this[i].parentElement.removeChild(this[i]);
- }
- }
- };
- window.addEventListener('message', function(e) {
- if (e.data.command == 'carrotquest.closePopup') {
- document.getElementById('carrot_frame_' + e.data.id).remove();
- carrotquest.identify([{ op: 'update_or_create', key: 'popup', value: 'closed' }]);
- carrotquest.track('Закрыл поп-ап', {
- 'id': e.data.id
- });
- };
- if (e.data.command == 'carrotquest.resizeFrame') {
- document.getElementById('carrot_frame_' + e.data.id).style.height = e.data.height + 'px';
- };
- });
- window.addEventListener('resize', function(event) {
- if (document.carrot_frame) {
- document.querySelector('iframe[name="carrot_frame"]').contentWindow.carrotquest.resizeFrame();
- };
- });
- }());
- //Попытка ухода с сайта
- (function() {
- init();
- function init() {
- setTimeout(addMouseout, 5000);
- };
- function addMouseout() {
- document.addEventListener('mouseout', mouseout);
- };
- function mouseout(e) {
- if (Math.round(e.x) >= 0 && Math.round(e.y) <= 0) {
- carrotquest.track('Попытка ухода с сайта');
- deleteEvent();
- setTimeout(addMouseout, 10000);
- }
- };
- function deleteEvent() {
- document.removeEventListener('mouseout', mouseout);
- };
- }());
- //Определяем есть ли поп-ап на странице
- if ($('iframe[id*="carrot_frame"]').length > 0) {
- carrotquest.identify([{op: 'update_or_create', key: 'popup', value: 'opened'}]);
- }
- else {
- carrotquest.identify([{op: 'update_or_create', key: 'popup', value: 'closed'}]);
- };
- carrotquest.identify([{op: 'update_or_create', key: 'Последняя посещенная страница', value: location.href}]);
- function getLocalDay(date) {
- var day = date.getDay();
- if (day == 0) {
- day = 7;
- }
- return day;
- }
- //запись текущего дня недели в свойство пользователя
- var date = new Date();
- var currentDay = getLocalDay(date);
- carrotquest.identify([{op: 'update_or_create', key: 'Текущий день недели', value: currentDay}]);
- //запись свойства "Скролл главной страницы до середины" и "Скролл главной страницы до конца"
- if (location.href == 'https://kuzmichnatali.ru/') {
- sessionStorage['isScrollMiddle'] = false;
- $(window).on('scroll', function() {
- if ($(window).scrollTop() >= ($(document).height() - $(window).height())*0.5) {
- if (sessionStorage['isScrollMiddle'] == 'false') {
- carrotquest.track('Скролл главной страницы до середины');
- sessionStorage['isScrollMiddle'] = true;
- };
- };
- });
- sessionStorage['isScrollEnd'] = false;
- $(window).on('scroll', function() {
- if ($(window).scrollTop() >= $(document).height() - $(window).height() - 100) {
- if (sessionStorage['isScrollEnd'] == 'false') {
- carrotquest.track('Скролл главной страницы до конца');
- sessionStorage['isScrollEnd'] = true;
- };
- };
- });
- }
- //Клики по элементам
- $(document).on('click', '#menu a[href="/courses"]', function() {
- carrotquest.track('Клик – Курсы');
- });
- $(document).on('click', '#menu a[href="/about"]', function() {
- carrotquest.track('Клик – Обо мне');
- });
- $(document).on('click', '#menu a[href="/faq"]', function() {
- carrotquest.track('Клик – Частые вопросы');
- });
- $(document).on('click', '.section_1 .start_btn', function() {
- carrotquest.track('Клик – Начать');
- });
- $(document).on('click', '.section_3 .start_btn', function() {
- carrotquest.track('Клик – Хочу');
- });
- $('.section_6 a.start_btn').eq(0).on('click', function() {
- carrotquest.track('Клик – Купить в Лабиринте');
- });
- $('.section_6 a.start_btn').eq(1).on('click', function() {
- carrotquest.track('Клик – Купить на Book24');
- });
- $(document).on('click', '.cabinet', function() {
- carrotquest.track('Клик – Личный кабинет ');
- });
- //Email
- $(document).on('blur', 'input[type="email"]', function() {
- carrotquest.identify([{op: 'update_or_create', key: '$email', value: $(this).val()}]);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement