25 $userAgent = $_SERVER[
'HTTP_USER_AGENT'];
28 $operatingSystemValues = array(
29 'windows' => array(
'NAME' =>
'Windows' ,
'REGEX' =>
'/windows|win98|win95|win16/i' ),
30 'macos' => array(
'NAME' =>
'Mac OS' ,
'REGEX' =>
'/macintosh|mac os x|mac_powerpc/i'),
31 'android' => array(
'NAME' =>
'Android' ,
'REGEX' =>
'/android/i' ),
32 'linux' => array(
'NAME' =>
'Linux' ,
'REGEX' =>
'/linux|ubuntu/i' ),
33 'ios' => array(
'NAME' =>
'iOS' ,
'REGEX' =>
'/iphone|ipod|ipad/i' ),
34 'blackberry' => array(
'NAME' =>
'BlackBerry',
'REGEX' =>
'/blackberry/i' ),
35 'webos' => array(
'NAME' =>
'Web OS' ,
'REGEX' =>
'/webos/i' ),
40 $browserValues = array(
41 'edge' => array(
'NAME' =>
'Edge',
'REGEX' =>
'/edge\//i'),
42 'ie' => array(
'NAME' =>
'Internet Explorer',
'REGEX' =>
'/msie|trident/i'),
43 'firefox' => array(
'NAME' =>
'Firefox',
'REGEX' =>
'/firefox/i' ),
44 'chrome' => array(
'NAME' =>
'Chrome',
'REGEX' =>
'/chrome/i' ),
45 'opera' => array(
'NAME' =>
'Opera',
'REGEX' =>
'/opera/i' ),
46 'safari' => array(
'NAME' =>
'Safari',
'REGEX' =>
'/safari/i' ),
47 'netscape' => array(
'NAME' =>
'Netscape',
'REGEX' =>
'/netscape/i' ),
48 'maxthon' => array(
'NAME' =>
'Maxthon',
'REGEX' =>
'/maxthon/i' ),
49 'konqueror' => array(
'NAME' =>
'Konqueror',
'REGEX' =>
'/konqueror/i'),
50 'mobile' => array(
'NAME' =>
'Handheld',
'REGEX' =>
'/mobile/i' ),
55 $searchEngineValues = array(
56 'google' => array(
'NAME' =>
'Google' ,
'REGEX' =>
'#^https?://www\.google\.[a-z]{2,3}/#' ),
57 'bing' => array(
'NAME' =>
'Bing' ,
'REGEX' =>
'#^https?://www\.bing\.[a-z]{2,3}/#' ),
58 'yahoo' => array(
'NAME' =>
'Yahoo' ,
'REGEX' =>
'#^https?://r\.search\.yahoo\.[a-z]{2,3}/#'),
59 'ask' => array(
'NAME' =>
'Ask' ,
'REGEX' =>
'#^https?://www\.ask\.[a-z]{2,3}/#' ),
60 'yandex' => array(
'NAME' =>
'Yandex' ,
'REGEX' =>
'#^https?://yandex\.[a-z]{2,3}/#' ),
61 'mail.ru' => array(
'NAME' =>
'Mail.ru',
'REGEX' =>
'#^https?://go\.mail\.ru/#' ),
62 'rambler' => array(
'NAME' =>
'Rambler',
'REGEX' =>
'#^https?://nova\.rambler\.ru/#' ),
69 'conversion_site' => array(
70 'MODULE' =>
'conversion',
73 'GET_VALUES' =>
function (array $ids)
77 $result = SiteTable::getList(array(
78 'select' => array(
'LID',
'NAME'),
79 'filter' => array(
'LID' => $ids),
80 'order' => array(
'SORT' =>
'ASC'),
83 while ($row = $result->fetch())
85 $values[$row[
'LID']] = array(
'NAME' => $row[
'NAME']);
90 'SET_DAY_CONTEXT' =>
function (
DayContext $dayContext)
94 $dayContext->setAttribute(
'conversion_site', $siteId);
101 'conversion_operating_system' => array(
102 'MODULE' =>
'conversion',
103 'NAME' =>
Loc::getMessage(
'CONVERSION_ATTRIBUTE_OPERATING_SYSTEM_NAME'),
105 'GET_VALUES' =>
function (array $ids) use ($operatingSystemValues)
109 foreach ($ids as $id)
111 if ($value = $operatingSystemValues[$id])
113 $values[$id] = $value;
119 'SET_DAY_CONTEXT' =>
function (
DayContext $dayContext) use ($operatingSystemValues, $userAgent)
123 foreach ($operatingSystemValues as $name => $type)
125 if (preg_match($type[
'REGEX'], $userAgent))
127 $dayContext->setAttribute(
'conversion_operating_system', $name);
137 'conversion_browser' => array(
138 'MODULE' =>
'conversion',
141 'GET_VALUES' =>
function (array $ids) use ($browserValues)
145 foreach ($ids as $id)
147 if ($value = $browserValues[$id])
149 $values[$id] = $value;
155 'SET_DAY_CONTEXT' =>
function (
DayContext $dayContext) use ($browserValues, $userAgent, & $browser)
159 foreach ($browserValues as $name => $type)
161 if (preg_match($type[
'REGEX'], $userAgent))
163 $dayContext->setAttribute(
'conversion_browser', $name);
174 'conversion_device_tablet' => array(
175 'MODULE' =>
'conversion',
179 'SPLIT_BY' =>
'conversion_operating_system',
180 'BG_COLOR' =>
'#be6ac4',
181 'SET_DAY_CONTEXT' =>
function (
DayContext $dayContext) use ($detector)
183 if ($detector->isTablet())
185 $dayContext->setAttribute(
'conversion_device_tablet');
190 'conversion_device_mobile' => array(
191 'MODULE' =>
'conversion',
195 'SPLIT_BY' =>
'conversion_operating_system',
196 'BG_COLOR' =>
'#4bbedb',
197 'SET_DAY_CONTEXT' =>
function (
DayContext $dayContext) use ($detector)
199 if ($detector->isMobile())
201 $dayContext->setAttribute(
'conversion_device_mobile');
206 'conversion_device_desktop' => array(
207 'MODULE' =>
'conversion',
211 'SPLIT_BY' =>
'conversion_browser',
212 'BG_COLOR' =>
'#cf4343',
213 'SET_DAY_CONTEXT' =>
function (
DayContext $dayContext) use (& $browser)
217 $dayContext->setAttribute(
'conversion_device_desktop');
224 'conversion_search_engine' => array(
225 'MODULE' =>
'conversion',
229 'SPLIT_BY' =>
'conversion_search_engine',
230 'BG_COLOR' =>
'#be6ac4',
231 'GET_VALUES' =>
function (array $ids) use ($searchEngineValues)
235 foreach ($ids as $id)
237 if ($value = $searchEngineValues[$id])
239 $values[$id] = $value;
245 'SET_DAY_CONTEXT' =>
function (
DayContext $dayContext) use ($searchEngineValues)
247 if ($referer = $_SERVER[
'HTTP_REFERER'])
249 foreach ($searchEngineValues as $name => $type)
251 if (preg_match($type[
'REGEX'], $referer))
253 $dayContext->setAttribute(
'conversion_search_engine', $name);