Commit 889ab655336bb813412be4233bac62076d8c8d49
1 parent
74783874
datalayer push
Showing
3 changed files
with
68 additions
and
2 deletions
Show diff stats
frontend/views/package/view.php
@@ -4,10 +4,22 @@ | @@ -4,10 +4,22 @@ | ||
4 | * @var \yii\web\View $this; | 4 | * @var \yii\web\View $this; |
5 | */ | 5 | */ |
6 | use common\models\Package; | 6 | use common\models\Package; |
7 | + use yii\web\View; | ||
8 | + | ||
7 | $seo = \Yii::$app->get('seo'); | 9 | $seo = \Yii::$app->get('seo'); |
8 | $this->params[ 'entity'] = Package::className(); | 10 | $this->params[ 'entity'] = Package::className(); |
9 | $this->params['entity_id'] = $package->id; | 11 | $this->params['entity_id'] = $package->id; |
10 | $this->params['breadcrumbs'][] = (!empty($seo->h1)) ? $seo->h1 :$package->title; | 12 | $this->params['breadcrumbs'][] = (!empty($seo->h1)) ? $seo->h1 :$package->title; |
13 | + | ||
14 | + $js = <<<JS | ||
15 | + $(document).on('beforeSubmit', '#visit-form', function() { | ||
16 | + window.dataLayer = window.dataLayer || []; | ||
17 | + window.dataLayer.push({'event': 'formsend_package'}); | ||
18 | + console.log('push'); | ||
19 | + return true; | ||
20 | + }); | ||
21 | +JS; | ||
22 | + $this->registerJs($js, View::POS_LOAD); | ||
11 | ?> | 23 | ?> |
12 | 24 | ||
13 | 25 |
frontend/views/service/view.php
@@ -10,6 +10,7 @@ | @@ -10,6 +10,7 @@ | ||
10 | use artbox\core\helpers\ImageHelper; | 10 | use artbox\core\helpers\ImageHelper; |
11 | use artbox\core\helpers\Url; | 11 | use artbox\core\helpers\Url; |
12 | use common\models\Service; | 12 | use common\models\Service; |
13 | + use yii\web\View; | ||
13 | 14 | ||
14 | $seo = \Yii::$app->get('seo'); | 15 | $seo = \Yii::$app->get('seo'); |
15 | $this->params['entity'] = Service::className(); | 16 | $this->params['entity'] = Service::className(); |
@@ -45,7 +46,52 @@ | @@ -45,7 +46,52 @@ | ||
45 | ]; | 46 | ]; |
46 | } | 47 | } |
47 | 48 | ||
48 | - | 49 | + |
50 | + $js = <<<JS | ||
51 | + $(document).on('beforeSubmit', '#comment-form', function() { | ||
52 | + window.dataLayer = window.dataLayer || []; | ||
53 | + dataLayer.push({'event': 'formsend_review'}); | ||
54 | + console.log('push'); | ||
55 | + return true; | ||
56 | + }); | ||
57 | + | ||
58 | +$(document).on('beforeSubmit', '#question-form', function() { | ||
59 | + window.dataLayer = window.dataLayer || []; | ||
60 | + dataLayer.push({'event': 'formsend_question'}); | ||
61 | + console.log('push'); | ||
62 | + return true; | ||
63 | + }); | ||
64 | + | ||
65 | + | ||
66 | + $(document).on('beforeSubmit', '#visit-form', function() { | ||
67 | + window.dataLayer = window.dataLayer || []; | ||
68 | + var service_id = {$model->id}; | ||
69 | + var parent_id = {$model->parent_id}; | ||
70 | + if (service_id == 4 || parent_id == 4){ | ||
71 | + window.dataLayer.push({'event': 'formsend_dermatologiya'}); | ||
72 | + } | ||
73 | + if (service_id == 16 || parent_id == 16){ | ||
74 | + dataLayer.push({'event': 'formsend_vedenie-beremennosti'}); | ||
75 | + } | ||
76 | + if (service_id == 22 || parent_id == 22){ | ||
77 | + dataLayer.push({'event': 'formsend_lechenie-besplodiya'}); | ||
78 | + } | ||
79 | + if (service_id == 21 || parent_id == 21){ | ||
80 | + dataLayer.push({'event': 'formsend_labioplastika'}); | ||
81 | + } | ||
82 | + if (service_id == 19 || parent_id == 19){ | ||
83 | + dataLayer.push({'event': 'formsend_zabolevaniya-sheyki-matki'}); | ||
84 | + } | ||
85 | + if (service_id == 20 || parent_id == 20){ | ||
86 | + dataLayer.push({'event': 'formsend_polovye-infekcii'}); | ||
87 | + } | ||
88 | + console.log('push'); | ||
89 | + return true; | ||
90 | + }); | ||
91 | +JS; | ||
92 | + | ||
93 | + $this->registerJs($js, View::POS_LOAD); | ||
94 | + | ||
49 | 95 | ||
50 | $this->params[ 'breadcrumbs' ][] = (!empty($seo->h1)) ? $seo->h1 :$model->title; | 96 | $this->params[ 'breadcrumbs' ][] = (!empty($seo->h1)) ? $seo->h1 :$model->title; |
51 | ?> | 97 | ?> |
frontend/web/js/script.js
@@ -381,7 +381,7 @@ $(document).ready(function() { | @@ -381,7 +381,7 @@ $(document).ready(function() { | ||
381 | $('.categories-home .img').click(function () { | 381 | $('.categories-home .img').click(function () { |
382 | var link = $(this).parent().find('.categories-home-links-title a').attr('href'); | 382 | var link = $(this).parent().find('.categories-home-links-title a').attr('href'); |
383 | document.location.href = link; | 383 | document.location.href = link; |
384 | - }) | 384 | + }); |
385 | var scrollPos = $(window).scrollTop(); | 385 | var scrollPos = $(window).scrollTop(); |
386 | var windHeight = $(window).height(); | 386 | var windHeight = $(window).height(); |
387 | var bl = $('.section-box-2'); | 387 | var bl = $('.section-box-2'); |
@@ -460,6 +460,14 @@ $(document).ready(function() { | @@ -460,6 +460,14 @@ $(document).ready(function() { | ||
460 | var form = $(this); | 460 | var form = $(this); |
461 | var id = form.attr('id'); | 461 | var id = form.attr('id'); |
462 | var url = form.attr('action'); | 462 | var url = form.attr('action'); |
463 | + window.dataLayer = window.dataLayer || []; | ||
464 | + if (id == 'total_question_form'){ | ||
465 | + dataLayer.push({'event': 'formsend_question'}); | ||
466 | + console.log('formsend_question'); | ||
467 | + }else{ | ||
468 | + dataLayer.push({'event': 'formsend_review'}); | ||
469 | + console.log('formsend_review'); | ||
470 | + } | ||
463 | $.post( | 471 | $.post( |
464 | $(this).attr("action"), $(this).serialize(), function(data) { | 472 | $(this).attr("action"), $(this).serialize(), function(data) { |
465 | document.getElementById(id).reset(); | 473 | document.getElementById(id).reset(); |