-
AuthorPosts
-
November 5, 2014 at 5:13 pm #346639
Hey,
I am trying to add analytics to the submit button. I have 2 problems:
1. I am using what I believe is a new analytics code – “ga(‘send’, ‘event’, ‘Contact Form’, ‘sent’);”
2. I need to add a second onclick event for yandex.metrika.Is it possible to have 2 onclick events for 1 button? If not I need only yandex.metrika.
Here is the code I used in Contact form 7:
on_sent_ok: “ga(‘send’, ‘event’, ‘Contact Form’, ‘sent’);” //// for GA
on_sent_ok: “yaCounter25372100.reachGoal(‘banktop’);” //// for yandex.metrikaI assume I have to sub this line – $att = “onclick=\”_gaq.push([‘_trackPageview’, ‘/VP/XXX/XXX’]);\””;
but there are so many random symbols like ‘ ( \ that I am not sure how exactly
add_filter('avf_contact_form_submit_button_attr','avia_add_submit_attributes_to_cf', 10, 3); function avia_add_submit_attributes_to_cf($att, $formID, $form_params){ $att = "onclick=\"_gaq.push(['_trackPageview', '/VP/XXX/XXX']);\""; return $att; }
November 6, 2014 at 6:33 am #346976Hey!
Use the onClick attribute for the yandex tracking so you can do something like this for GA.
Cheers!
JosueNovember 6, 2014 at 3:34 pm #347115Yeah that would work, but how exactly my code will look like
add_filter(‘avf_contact_form_submit_button_attr’,’avia_add_submit_attributes_to_cf’, 10, 3);
function avia_add_submit_attributes_to_cf($att, $formID, $form_params){
$att = “onclick=\”yaCounter25372100.reachGoal(‘banktop’);\””;
return $att;
}looks good?
Thanks
November 6, 2014 at 6:56 pm #347261Yes, that should work.
Best regards,
JosueNovember 11, 2014 at 3:12 pm #349381Unfortunately it doesn’t track submits
//ya.metrika for submit button
add_filter(‘avf_contact_form_submit_button_attr’,’avia_add_submit_attributes_to_cf’, 10, 3);
function avia_add_submit_attributes_to_cf($att, $formID, $form_params){
$att = “onclick=\”yaCounter25238750.reachGoal(‘realty’);\””;
return $att;
}I’ve triple checked counter # and goal id and its correct, but for some reason it doesn’t work
November 11, 2014 at 6:32 pm #349592Hi!
Re-do the button on a simple HTML page (/test.html) to discard.
Cheers!
JosueSeptember 27, 2016 at 5:14 pm #692355Hello,
I need to make same modifications with metrika event, but I don’t understand where to paste this code? I found something similar in functions.php, but not exactly the same. Help me please to understand.And i have one more question how to make facebook pixel work on the same event?
i made like this:
<!– Facebook Pixel Code –>
<script>
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;n.version=’2.0′;n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
document,’script’,’https://connect.facebook.net/en_US/fbevents.js’);fbq(‘init’, ‘129921544130465’);
fbq(‘track’, ‘AddToCart’);
</script>
<noscript><img height=”1″ width=”1″ style=”display:none”
src=”https://www.facebook.com/tr?id=129921544130465&ev=PageView&noscript=1″
/></noscript>
<!– End Facebook Pixel Code –>Added this to link contact form submit button to pixel:
<script>
(function($){
$(window).load(function() {
$(‘.button a’).on(‘click’, function() {fbq(‘track’, ‘AddToCart’);
});})(jQuery);
</script>but it works wrong i think, because advertising said i have a lot of conversions but i have no letters from my website… something wrong.
September 27, 2016 at 6:18 pm #692368Hi,
The code should only run if form validation has passed.
<script> (function($){ $('.avia_ajax_form .button').on('click', function(){ setTimeout(function(){ if(!$('.form_element.error').length > 0) { fbq(‘track’, ‘AddToCart’); } },100); }); })(jQuery); </script>
Best regards,
JosueOctober 5, 2016 at 1:40 pm #695462Just see the answer!
Thank you!
Where should I insert it? in functions.php?
or maybe in google services tab?- This reply was modified 8 years, 1 month ago by niobeer.
October 5, 2016 at 2:31 pm #695493Hi,
On a code block below the form.
Best regards,
JosueOctober 5, 2016 at 4:31 pm #695591Thank you, will test it!
October 6, 2016 at 7:49 am #695888October 7, 2016 at 2:00 pm #696492something goes wrong, on 5 of October i have 800+ pixel trafic include 400+ add to cart. but still no one letter from my form.
October 7, 2016 at 2:06 pm #696501Hi,
Unfortunately it would require quite some time to debug and find the issue why it is not sending, so I am sorry to tell you that this is not covered by our support.
However if its really important for you to get this done, you can always hire a freelancer to do the job for you :)Best regards,
Basilis- This reply was modified 8 years, 1 month ago by Basilis.
-
AuthorPosts
- You must be logged in to reply to this topic.