V
V
Vladimir2017-03-23 10:46:50
1C-Bitrix
Vladimir, 2017-03-23 10:46:50

How to add a Yandex metric target to a button in Bitrix?

Hello. They asked me to set a metric and add goals on the site on Bitrix.
But the fact is that there is such a button:

<button class="basket" 
onclick='add(<?=$arResult["ID"]?>,<?=$arResult["PREVIEW_PICTURE"]["SRC"]?>)'>Добавить в корзину</button>

Accordingly, the standard way onclick = "yaCounterXXXXXX.reachGoal('CART'); return true;" - it's not gonna go. How can I add a target to this onclick?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
VladimirPortev, 2017-03-23
Portev @Vladimir Portev

All. It's just me being a fool. It was necessary to write not 'CART', but "CART" - quotes!

A
Alexey Likhachev, 2017-03-23
@Playbot

I think this will suit you

<button class="basket" 
onclick='yaCounterXXXXXX.reachGoal('CART');add(<?=$arResult["ID"]?>,<?=$arResult["PREVIEW_PICTURE"]["SRC"]?>)'>Добавить в корзину</button>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question