Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #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.metrika

    I 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;
    }
    #346976

    Hey!

    Use the onClick attribute for the yandex tracking so you can do something like this for GA.

    Cheers!
    Josue

    #347115

    Yeah 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

    #347261

    Yes, that should work.

    Best regards,
    Josue

    #349381

    Unfortunately 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

    #349592

    Hi!

    Re-do the button on a simple HTML page (/test.html) to discard.

    Cheers!
    Josue

    #692355

    Hello,
    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&#8217;);

    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&#8243;
    /></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.

    #692368

    Hi,

    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,
    Josue

    #695462

    Just 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, 2 months ago by niobeer.
    #695493

    Hi,

    On a code block below the form.

    Best regards,
    Josue

    #695591

    Thank you, will test it!

    #695888

    Hi,

    Great, let us know if you should have any problems.

    Regards,
    Rikard

    #696492

    something goes wrong, on 5 of October i have 800+ pixel trafic include 400+ add to cart. but still no one letter from my form.

    #696501

    Hi,

    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, 2 months ago by Basilis.
Viewing 14 posts - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.