• Модуль: landing
  • Путь к файлу: ~/bitrix/modules/landing/lib/hook/page/gacounter.php
  • Класс: BitrixLandingHookPageGaCounter
  • Вызов: GaCounter::exec
public function exec()
{
	if ($this->execCustom())
	{
		return;
	}

	if ($this->fields['USE']->getValue() != 'Y')
	{
		return;
	}

	//Universal Analytics
	$this->setCounter($this->fields['COUNTER']);
	//Google Analytics 4
	$this->setCounter($this->fields['COUNTER_GA4']);

	// send analytics
	$sendData = [];
	if ($this->fields['SEND_CLICK']->getValue() == 'Y')
	{
		$sendData[] = 'click';
	}
	if ($this->fields['SEND_SHOW']->getValue() == 'Y')
	{
		$sendData[] = 'show';
	}
	if (!empty($sendData))
	{
		BitrixLandingManager::setPageView(
			'BodyTag',
			' data-event-tracker='' . json_encode($sendData) . '''
		);
		$clickType = $this->fields['CLICK_TYPE']->getValue();
		if (!$clickType)
		{
			$clickType = 'text';
		}
		if ($clickType)
		{
			BitrixLandingManager::setPageView(
				'BodyTag',
				' data-event-tracker-label-from="' . htmlspecialcharsbx($clickType) . '"'
			);
		}
	}
}