S
S
Strelcov2019-04-07 13:32:24
JavaScript
Strelcov, 2019-04-07 13:32:24

How to add onclick to DIV via JS for Yandex Metrics?

Hello. Tell me, you need to wrap the ad block from AdSense in a DIV and hang a goal on click on this DIV (as I understand it, an event)
Will this work?

<div class="test" onclick="ym(XXXXXX, 'reachGoal', 'TARGET_NAME'); return true;" ></div>

If not, I'll be glad for a working version!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir, 2019-04-07
@Casufi

Google learn JavaScript event handling

M
Moses Fender, 2019-05-02
@mosesfender

The click will work on the ad, not the wrapper. You need to click on the advertisement to look for a wrapper. For example, through closest()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question