MailPoet Button OnClick

Hi there, guys! I don’t know, is my question “out of scope” or not, but i will try…

I need to track click event on mailpoet subscribe button. It’s all about Google Analytics and Yandex Metrika…

I’m already done with Contact Form 7 and X Pro button:

Contact Form 7

<script type="text/javascript">
document.addEventListener( 'wpcf7mailsent', function( event ) {
    yaCounter52890739.reachGoal('orderSpecialistCallFormSend');
    ga('send', 'event', 'Отслеживание форм', 'Заказать звонок - форма');
}, false );
</script>

X Pro Button:

Add class to a button ga-event-call

Add JS to Theme Options

jQuery(document).ready(function($){
	$('.ga-event-call').on('click', function(){
		yaCounter52890739.reachGoal('orderSpecialistCallButtonClick');
    ga('send', 'event', 'Отслеживание форм', 'Заказать звонок - кнопка');
	});
});

Now it’s MailPoet time. Can you suggest, there should i start from?

Hello Philipp,

Thanks for writing in!

Please take a look at following tutorial:

Thanks.

1 Like

Thanks, bro! But i need to TRACK CLICKS on button of mailpoet subscribe form. And i need to track it not only with Google Analytics, there is a Yandex Metrika too. Mail poet form inserted in Content Area element with a shortcode, so i cannot give a button a class, like i’ve done with X Pro Button element with JS…

These links i’ve already examine…

Mail poet button has a class “mailpoet_submit”. Can it use this code to get things right?

jQuery(document).ready(function($){
	$('.mailpoet_submit').on('click', function(){
		yaCounter52890739.reachGoal('orderSpecialistCallButtonClick');
        ga('send', 'event', 'Отслеживание форм', 'Заказать звонок - кнопка');
	});
});

Hi @Georgich,

You can try with this custom JS instead:

jQuery(document).ready(function($){
	$('.mailpoet_form').on('submit', function(){
		yaCounter52890739.reachGoal('orderSpecialistCallButtonClick');
        	ga('send', 'event', 'Отслеживание форм', 'Заказать звонок - кнопка');
	});
});

Let us know how it goes!

1 Like

DAT WORKS! ) Thank you, BRO :yum:

You’re most welcome.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.