D
D
Denis Shishkin2016-09-20 11:40:49
JavaScript
Denis Shishkin, 2016-09-20 11:40:49

How to correctly register Yandex target event on a regular button?

I can’t figure out how to correctly write the goal-event for the Yandex metric in the button code. Here's a screencap of the code:

<div id="mk-button-11" class="mk-button-container _ relative   mk-animate-element flip-x   block text-center  twf mk-in-viewport">
  <a href="#" target="_self" class="mk-button js-smooth-scroll mk-button--dimension-flat mk-button--size-large mk-button--corner-pointed text-color-dark _ relative text-center font-weight-700 no-backface  letter-spacing-2 inline">
         
    <span class="mk-button--text">ПОЛУЧИТЬ БИЛЕТ</span>
      </a>
</div>

I understand that I need to insert this piece into the code above:
onclick="yaCounter39276445.reachGoal('buyclick');
But I can’t understand where exactly..
I looked at the Yandex website, there is an example only for the submit button of the form..
Thank you in advance for your help!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Yanchevsky, 2016-09-20
@DeniSShishkin

If the button is a link, then in the link attributes.

<div id="mk-button-11" class="mk-button-container _ relative   mk-animate-element flip-x   block text-center  twf mk-in-viewport">
  <a onclick="yaCounter39276445.reachGoal('buyclick');" href="#" target="_self" class="mk-button js-smooth-scroll mk-button--dimension-flat mk-button--size-large mk-button--corner-pointed text-color-dark _ relative text-center font-weight-700 no-backface  letter-spacing-2 inline">
         
    <span class="mk-button--text">ПОЛУЧИТЬ БИЛЕТ</span>
      </a>
</div>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question