Website is on wordpress with contact form 7 plugin installed.
I was connected to Yandex metric, set the goal and tap addEventListener
to forms, but I can not understand why the goals don't reach, although mails delivered..
I try to do it different ways, but couldn't find any errors in the console.
addEventListener ( 'wpcf7mailsent')
don't work..
<!-- Yandex.Metrika counter -->
<script type="text/javascript" >
(function(m,e,t,r,i,k,a){m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)};
m[i].l=1*new Date();k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)})
(window, document, "script", "https://mc.yandex.ru/metrika/tag.js", "ym");
ym(41441674, "init", {
clickmap:true,
trackLinks:true,
accurateTrackBounce:true,
webvisor:true
});
</script>
<noscript><div><img src="https://mc.yandex.ru/watch/41441674" style="position:absolute; left:-9999px;" alt="" /></div></noscript>
<!-- /Yandex.Metrika counter -->
<script type="text/javascript">
document.addEventListener( 'wpcf7mailsent', function( event ) {
ym(41441674, 'reachGoal', 'weddings'); return true;
console.log('weddings');
});
var wpcf7Elm = document.querySelector( '.wpcf7' );
wpcf7Elm.addEventListener ( 'wpcf7mailsent', function( event ) {
ym(41441674, 'reachGoal', 'zayavka');
console.log('zayavka');
}, false);
document.addEventListener ( 'wpcf7submit', function( event ) {
ym(41441674, 'reachGoal', 'zayavka');
console.log('wpcf7submit');
}, false);
</script>