Google goals and region detection

master
fefa4ka 10 years ago
parent c4ac0a6da6
commit 6ed8f28274
  1. 2
      djangocms_forms/templates/djangocms_forms/form_template/default.html
  2. 63
      zsite/static/js/snippets.js
  3. 5
      zsite/templates/form_template/consultation.html
  4. 5
      zsite/templates/form_template/order_modal.html

@ -49,7 +49,7 @@ var form = {
</div>
{% endif %}
<div class="form-wrapper">
<form action="{{ form.submission_url }}" method="POST" enctype="multipart/form-data" onsubmit="yaCounter950321.reachGoal('FormStep'); return true;">
<form action="{{ form.submission_url }}" method="POST" enctype="multipart/form-data" onsubmit="yaCounter950321.reachGoal('FormStep'); ga('send', 'event', 'Service', 'step'); return true;">
<div class="form-errors" style="display:none;"></div>
{% for field in form.visible_fields %}
<div class="field-wrapper {{ field|input_class }} {{ field.css_classes }}">

@ -28,9 +28,72 @@ setCookie = function(key, value) {
document.cookie = key + '=' + value + ';expires=' + expires.toUTCString() + ';path=/';
};
getCookie = function(name) {
var matches = document.cookie.match(new RegExp(
"(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
));
return matches ? decodeURIComponent(matches[1]) : undefined;
}
detectRegion = function() {
function renderRegionData(current_region) {
var regions = {
'Moscow': {
'city': 'В Москве',
'phone': '+7 495 775-16-37'
},
'St.-Petersburg': {
'city': 'В Санкт Петербурге',
'phone': '+7 800 700-16-37'
},
'Rostov': {
'city': 'В Ростове-на-Дону',
'phone': '+7 863 209-85-65'
},
'Krasnodarskiy Kray': {
'city': 'В Ростове-на-Дону',
'phone': '+7 863 209-85-65'
},
'Volgogradskaya Oblast': {
'city': 'В Ростове-на-Дону',
'phone': '+7 863 209-85-65'
},
'Voronezhskaya Oblast': {
'city': 'В Ростове-на-Дону',
'phone': '+7 863 209-85-65'
}
};
console.log(current_region);
if(typeof current_region !== "undefined") {
$('.city').text(regions[current_region]['city']);
$('.header-contacts .consultation h3').text(regions[current_region]['phone']);
}
}
if(typeof getCookie('region') === undefined || getCookie('region') == "") {
var request = $.get('http://ip-api.com/json')
request.done(function(data) {
setCookie('region', data.regionName);
renderRegionData(data.regionName);
});
} else {
renderRegionData(getCookie('region'));
}
};
$(function() {
$( "[href^=mailto]" ).click(function() {
yaCounter950321.reachGoal('EmailClick');
ga('send', 'event', 'Communication', 'email');
});
$( "[href^='#service-form-submit']" ).click(function(e) {

@ -18,7 +18,7 @@
</div>
{% endif %}
<div class="form-wrapper">
<form action="{{ form.submission_url }}" method="POST" enctype="multipart/form-data" onsubmit="yaCounter950321.reachGoal('Callback'); return true;">
<form action="{{ form.submission_url }}" method="POST" enctype="multipart/form-data" onsubmit="yaCounter950321.reachGoal('Callback'); ga('send', 'event', 'Communication', 'callback'); return true;">
<div class="form-errors" style="display:none;"></div>
<div class="field-wrapper">
@ -97,7 +97,7 @@
</div>
</script>
<button class="btn btn-consultation" ng-click="open('{{ instance.id }}');" onclick="yaCounter950321.reachGoal('CallbackOpen'); return true;" value="">{{ instance.title }}</button>
<button class="btn btn-consultation" ng-click="open('{{ instance.id }}');" onclick="yaCounter950321.reachGoal('CallbackOpen'); ga('send', 'event', 'Communication', 'callback_open'); return true;" value="">{{ instance.title }}</button>
</div>
@ -112,6 +112,7 @@
angular.element($('.consultation-form')[0]).scope().open({{ instance.id }});
yaCounter950321.reachGoal('CallbackOpen');
ga('send', 'event', 'Communication', 'callback_open');
});
consultation_link = true;

@ -22,7 +22,7 @@
</div>
{% endif %}
<div class="form-wrapper">
<form action="{{ form.submission_url }}" method="POST" enctype="multipart/form-data" onsubmit="yaCounter950321.reachGoal('Order'); return true;">
<form action="{{ form.submission_url }}" method="POST" enctype="multipart/form-data" onsubmit="yaCounter950321.reachGoal('Order'); ga('send', 'event', 'Service', 'order'); return true;">
<div class="form-errors" style="display:none;"></div>
<div class="field-wrapper">
@ -101,7 +101,7 @@
</div>
</script>
<button class="btn btn-consultation xs-offset-bottom" ng-click="open('{{ instance.id }}');" onclick="yaCounter950321.reachGoal('OrderOpen'); return true;" value="">{{ instance.title }}</button>
<button class="btn btn-consultation xs-offset-bottom" ng-click="open('{{ instance.id }}');" onclick="yaCounter950321.reachGoal('OrderOpen'); ga('send', 'event', 'Service', 'order_open'); return true;" value="">{{ instance.title }}</button>
{% if request.LANGUAGE_CODE == 'ru' %}
<p>Вы можете <em>обратить к нам с вопросом</em> или <em>заказать услугу</em> «{{ instance.name }}»</p>
{% else %}
@ -120,6 +120,7 @@
angular.element($('.order-form')[0]).scope().open({{ instance.id }});
yaCounter950321.reachGoal('OrderOpen');
ga('send', 'event', 'Service', 'order_open');
});
consultation_link = true;

Loading…
Cancel
Save