1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
gtm.php
См. документацию.
1<?php
2namespace Bitrix\Landing\Hook\Page;
3
4use \Bitrix\Landing\Manager;
5use \Bitrix\Landing\Field;
6use \Bitrix\Main\Localization\Loc;
7
8Loc::loadMessages(__FILE__);
9
11{
16 protected function getMap()
17 {
18 $helpUrl = \Bitrix\Landing\Help::getHelpUrl('GTM');
19 return array(
20 'USE' => new Field\Checkbox('USE', array(
21 'title' => 'Google Tag Manager'
22 )),
23 'COUNTER' => new Field\Text('COUNTER', array(
24 'title' => 'Google Tag Manager',
25 'placeholder' => Loc::getMessage('LANDING_HOOK_GTM_PLACEHOLDER'),
26 'help' => $helpUrl
27 ? '<a href="' . $helpUrl . '" target="_blank">' .
28 Loc::getMessage('LANDING_HOOK_DETAIL_HELP') .
29 '</a>'
30 : ''
31 ))
32 );
33 }
34
39 public function isFree()
40 {
41 return false;
42 }
43
48 public function isLocked()
49 {
51 'limit_sites_google_analytics'
52 );
53 }
54
59 public function enabled()
60 {
61 if ($this->isLocked())
62 {
63 return false;
64 }
65
66 if ($this->issetCustomExec())
67 {
68 return true;
69 }
70
71 return $this->fields['USE']->getValue() == 'Y';
72 }
73
78 public function enabledInEditMode()
79 {
80 return false;
81 }
82
87 public function exec()
88 {
89 if ($this->execCustom())
90 {
91 return;
92 }
93
94 $counter = \htmlspecialcharsbx(trim($this->fields['COUNTER']));
95 $counter = \CUtil::jsEscape($counter);
96 if ($counter)
97 {
99 'gtm',
100 '(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({\'gtm.start\':new Date().getTime(),event:\'gtm.js\'});
101 var f=d.getElementsByTagName(s)[0],
102 j=d.createElement(s),
103 dl=l!=\'dataLayer\'?\'&l=\'+l:\'\';
104 j.async=true;
105 j.src=\'https://www.googletagmanager.com/gtm.js?id=\'+i+dl;
106 f.parentNode.insertBefore(j,f);})(window,document,\'script\',\'dataLayer\',\'' . $counter . '\');'
107 );
108 Manager::setPageView(
109 'Noscript',
110 '<noscript>
111 <iframe src="https://www.googletagmanager.com/ns.html?id=' . $counter . '" height="0" width="0" style="display:none;visibility:hidden"></iframe>
112 </noscript>');
113 }
114 }
115}
static getHelpUrl(string $code)
Определения help.php:174
static addCookieScript(string $cookieCode, string $functionBody)
Определения cookies.php:167
isLocked()
Определения gtm.php:48
getMap()
Определения gtm.php:16
enabledInEditMode()
Определения gtm.php:78
enabled()
Определения gtm.php:59
exec()
Определения gtm.php:87
isFree()
Определения gtm.php:39
issetCustomExec()
Определения page.php:253
execCustom()
Определения page.php:262
static isAllowed(string $code, array $params=[], string $cacheSalt='')
Определения manager.php:214
hidden PROPERTY[<?=$propertyIndex?>][CODE]<?=htmlspecialcharsEx( $propertyCode)?> height
Определения file_new.php:759
bx popup label bx width30 PAGE_NEW_MENU_NAME text width
Определения file_new.php:677
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
Определения tools.php:2701
Определения checkbox.php:2
Определения base32.php:2
$counter
Определения options.php:5
font style
Определения invoice.php:442