Commit ba6b05483372e7e69c0b62f46361735333738be3
1 parent
570ff1f7
-Added analytics events
Showing
2 changed files
with
43 additions
and
11 deletions
Show diff stats
frontend/views/layouts/main.php
| @@ -77,20 +77,9 @@ | @@ -77,20 +77,9 @@ | ||
| 77 | 77 | ||
| 78 | <title><?= Html::encode($seo->title) ?></title> | 78 | <title><?= Html::encode($seo->title) ?></title> |
| 79 | <link rel="icon" type="image/vnd.microsoft.icon" href="/img/favicon.ico"> | 79 | <link rel="icon" type="image/vnd.microsoft.icon" href="/img/favicon.ico"> |
| 80 | - <!-- Google Tag Manager --> | ||
| 81 | - <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': | ||
| 82 | - new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], | ||
| 83 | - j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= | ||
| 84 | - 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); | ||
| 85 | - })(window,document,'script','dataLayer','GTM-TSCLJL');</script> | ||
| 86 | - <!-- End Google Tag Manager --> | ||
| 87 | <?php $this->head() ?> | 80 | <?php $this->head() ?> |
| 88 | </head> | 81 | </head> |
| 89 | <body> | 82 | <body> |
| 90 | - <!-- Google Tag Manager (noscript) --> | ||
| 91 | - <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-TSCLJL" | ||
| 92 | - height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> | ||
| 93 | - <!-- End Google Tag Manager (noscript) --> | ||
| 94 | <?php $this->beginBody() ?> | 83 | <?php $this->beginBody() ?> |
| 95 | <script async src="https://www.googletagmanager.com/gtag/js?id=UA-83015473-1"></script> | 84 | <script async src="https://www.googletagmanager.com/gtag/js?id=UA-83015473-1"></script> |
| 96 | <script> | 85 | <script> |
frontend/web/js/script.js
| @@ -145,6 +145,49 @@ $( | @@ -145,6 +145,49 @@ $( | ||
| 145 | $(".send-form").attr('id', 'callback'); | 145 | $(".send-form").attr('id', 'callback'); |
| 146 | }); | 146 | }); |
| 147 | 147 | ||
| 148 | + $(document).on('click', '.send-form', function() { | ||
| 149 | + var id = $(this).attr('id'); | ||
| 150 | + switch (id) { | ||
| 151 | + case 'consultation' : | ||
| 152 | + gtag('event', 'send', { | ||
| 153 | + 'event_category': 'consultation' | ||
| 154 | + }); | ||
| 155 | + console.log(id); | ||
| 156 | + break; | ||
| 157 | + case 'specialist' : | ||
| 158 | + gtag('event', 'send', { | ||
| 159 | + 'event_category': 'specialist' | ||
| 160 | + }); | ||
| 161 | + console.log(id); | ||
| 162 | + break; | ||
| 163 | + case 'calculate' : | ||
| 164 | + gtag('event', 'send', { | ||
| 165 | + 'event_category': 'calculate' | ||
| 166 | + }); | ||
| 167 | + console.log(id); | ||
| 168 | + break; | ||
| 169 | + case 'order' : | ||
| 170 | + gtag('event', 'send', { | ||
| 171 | + 'event_category': 'order' | ||
| 172 | + }); | ||
| 173 | + console.log(id); | ||
| 174 | + break; | ||
| 175 | + case 'call' : | ||
| 176 | + gtag('event', 'send', { | ||
| 177 | + 'event_category': 'call' | ||
| 178 | + }); | ||
| 179 | + console.log(id); | ||
| 180 | + break; | ||
| 181 | + case 'callback' : | ||
| 182 | + gtag('event', 'send', { | ||
| 183 | + 'event_category': 'callback' | ||
| 184 | + }); | ||
| 185 | + console.log(id); | ||
| 186 | + break; | ||
| 187 | + default: | ||
| 188 | + console.log('Id didn\'t match any case') | ||
| 189 | + } | ||
| 190 | + }); | ||
| 148 | 191 | ||
| 149 | function phoneMask(maskCssSelector) { | 192 | function phoneMask(maskCssSelector) { |
| 150 | var phoneInput = maskCssSelector; | 193 | var phoneInput = maskCssSelector; |