V
V
Vitaly2018-04-18 19:13:28
1C-Bitrix
Vitaly, 2018-04-18 19:13:28

How to collect link click statistics?

There is a link to the phone a href="tel:" you need to collect the number of clicks from it and display it in the admin panel.
Started infoblock, element. I'm making an ajax request to a link.
Processing request:

$ELEMENT_ID = 3668;  // код элемента
$PROPERTY_CODE = "jump";
$arSelect = Array(
 'ID', 
 'PROPERTY_jump'
);
$arFilter = Array("IBLOCK_ID" => 25, "ACTIVE"=>"Y", "ID"=>$ELEMENT_ID);
$res = CIBlockElement::GetList(Array(), $arFilter, false, false, $arSelect);
while($rs = $res->Fetch())
{
  $trueCount=$rs["PROPERTY_JUMP_VALUE"]; //вытаскиваю свойство элемента, куда нужно записать
  $PROPERTY_VALUE = $trueCount+1; // к текущему значению плюсую 1.
  CIBlockElement::SetPropertyValuesEx($ELEMENT_ID, 25, array($PROPERTY_CODE => $PROPERTY_VALUE)); //записываю новое значение
};

The question is how adequate and viable this method is in production!?
Tell me plz!!!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Nikolaev, 2018-04-19
@vcherepko

As for me - so the decision with +1 in the element and ajax sending is not the best idea.
I would connect some Yandex.Metrica, set the target to click on a link, and receive reports via the API in the admin panel. If it is very important to keep it at home, then you can take information once a day.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question