Tell me how to implement the feature, so that the click on any button of the "Share" block is tracked, and if it is pressed to put a cookie.
- oneand an example of a button that you can use? - Goshka Tarasov
|
2 answers
When programmatically initializing a block, you can determine the onshare hook that is triggered when a button is pressed:
Ya.share2('my-share', { hooks: { onshare: function (name) { alert('нажата кнопка' + name); } } }); |
Yes, it is quite a real one. When viewing the item code, you can see that each button has its own unique class. To him and approach. Like that:
$(".ya-share2").on( "click", ".ya-share2__item_service_vkontakte", function() { // нажали на "поделиться в ВК". Делаем, что хотим }); However, if you have a task to change something on the page, in cases if the user is “shared”, then this method is not reliable, since no one will prevent the user from closing the window after clicking on the button, and you will write down the cookie.
- my popup pops up, I want to keep track of those who shared and do not show them again - Anton Veselov
|