Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
pixelvk.php
1<?php
3
4use \Bitrix\Landing\Field;
5use \Bitrix\Main\Localization\Loc;
6use \Bitrix\Landing\Manager;
7
8Loc::loadMessages(__FILE__);
9
11{
16 protected function getMap()
17 {
18 $helpUrl = \Bitrix\Landing\Help::getHelpUrl('PIXEL');
19 return array(
20 'USE' => new Field\Checkbox('USE', array(
21 'title' => Loc::getMessage('LANDING_HOOK_PIXEL_VK_USE')
22 )),
23 'COUNTER' => new Field\Text('COUNTER', array(
24 'title' => Loc::getMessage('LANDING_HOOK_PIXEL_VK_COUNTER'),
25 'placeholder' => Loc::getMessage('LANDING_HOOK_PIXEL_VK_PLACEHOLDER2'),
26 'help' => $helpUrl
27 ? '<a href="' . $helpUrl . '" target="_blank">' .
28 Loc::getMessage('LANDING_HOOK_PIXEL_VK_HELP') .
29 '</a>'
30 : ''
31 ))
32 );
33 }
34
39 public function enabledInEditMode()
40 {
41 return false;
42 }
43
48 public function enabled()
49 {
50 if ($this->issetCustomExec())
51 {
52 return true;
53 }
54
55 return $this->fields['USE']->getValue() == 'Y';
56 }
57
62 public function exec()
63 {
64 if ($this->execCustom())
65 {
66 return;
67 }
68
69 $counter = \htmlspecialcharsbx(trim($this->fields['COUNTER']));
70 $counter = \CUtil::jsEscape($counter);
71 if ($counter)
72 {
74 'vkp',
75 '!function(){
76 var t=document.createElement("script");
77 t.type="text/javascript",
78 t.async=!0,
79 t.src="https://vk.com/js/api/openapi.js?160",
80 t.onload=function(){VK.Retargeting.Init("' . $counter . '"),
81 VK.Retargeting.Hit()},document.head.appendChild(t)
82 }();'
83 );
85 'Noscript',
86 '<noscript>
87 <img src="https://vk.com/rtrg?p=' . $counter . '" style="position:fixed; left:-999px;" alt=""/>
88 </noscript>'
89 );
90 }
91 }
92}
static addCookieScript(string $cookieCode, string $functionBody)
Definition cookies.php:167
static setPageView(string $marker, string $content, bool $skipTrim=false)
Definition manager.php:465
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29