Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #455070

    Hello.
    I need to be able to track form submissions from Contact Form. There’s no URL redirect option for a “Thank You” page, because of what is not possible to adjust the target for the link.
    Goals should be set for Google Analytics (https://support.google.com/analytics/answer/1032415?hl=en&ref_topic=6150889) and Yandex.Metrica (http://help.yandex.com/metrica/qanda/goals-qanda.xml) in Child Theme, In which there is only the file “functions.php”.

    #455332

    Hi Bearded!

    Please see here, http://kriesi.at/documentation/enfold/add-onclick-event-to-the-contact-form-submit-button/.

    For the yandex metrica try this.

    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']); yaCounterCOUNTER_ID.reachGoal('TARGET_NAME'); return true; \"";
      return $att;
    }

    Regards,
    Elliott

    • This reply was modified 9 years, 5 months ago by Elliott.
    #903368

    it is fantastically uncomfortable. is it not possible to make a field in the component settings, to enter a javascript event??

    #904467

    Hi,

    No, there is no visual way for that
    Some things, do require coding to be achieved.

    Best regards,
    Basilis

    #1059014

    Hi, few days ago new metrika start to work and new syntaxis:
    https://yandex.com/support/metrica/objects/reachgoal.html

    I made next code to instert in functions.php:

    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=”ym(44799976, ‘reachGoal’, ‘contact_form_click_camp’); return true;” value=”Order”;”
    return $att;
    }

    And always with a error, can you pls help?

    #1059831

    Hi,

    Can u post the function for example to pastebin so we can see the code properly? I can see that ‘ is wrong, but still want to confirm.

    Best regards,
    Basilis

    #1062295

    Problem that it always with a syntaxis error. Here is manual:

    <form action=””>

    <input type=”button” onclick=”ym(XXXXXX, ‘reachGoal’, ‘TARGET_NAME’); return true;” value=”Order” />
    </form>
    …:

    For test i made GA similar tracking – it works perfect. But with YM i can’t do the same:
    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){
    $gaq = “_gaq.push([‘_trackPageview’, ‘UA-98919545-2’]);\””;
    $att = “onclick=\”ga(‘send’, ‘event’, ‘Request’, ‘Send’, ‘CF_Enfold’);\” “;
    $att = “onclick=\”ym(44799976, ‘reachGoal’, ‘contact_form_click_camp’); return true; value=”Order”;\” “;
    return $att;
    }

    syntax error, unexpected ‘Order’ (T_STRING)

    #1063869

    Hi,

    Forget my previous reply. You have to replace the wrapper of the “Order” value with single quotes.

    return true; value='Order';\”
    

    Best regards,
    Ismael

    #1063872

    Hi,

    UPDATE: And you can’t use two onclick attributes on the same button. The code should look like this:

    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){
    $gaq = "_gaq.push(['_trackPageview', 'UA-98919545-2']);\"";
    $att = "onclick=\"ga('send', 'event', 'Request', 'Send', 'CF_Enfold'); ym(44799976, 'reachGoal', 'contact_form_click_camp'); return true;\" value=\"Order\"";
    return $att;
    }
    

    I’m not sure if it’s going to fire both function but that should be a valid code.

    Best regards,
    Ismael

    #1064554

    Hello,

    Thank you very much for your great work!

    #1064877

    Hi KidLoop,

    Great, I’m glad we could help. Please let us know if you should need any further help on the topic.

    Best regards,
    Rikard

    #1139370

    Hello,
    Sorry, may be polar bear dead,bu it doesn’t work…
    I made a GA goal:
    Request
    Send
    CF_Enfold
    1

    And my tracking code is:
    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){
    $gaq = “_gaq.push([‘_trackPageview’, ‘UA-98919545-5’]);\””;
    $att = “onclick=\”ga(‘send’, ‘event’, ‘Request’, ‘Send’, ‘CF_Enfold’); return true;\” value=\”Order\””;
    return $att;
    }

    But it doesnt track any activity… and i tryed that code:
    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){
    $gaq = “_gaq.push([‘_trackPageview’, ‘UA-98919545-5’]);”;
    $att = “onclick=\”ga(‘send’, ‘event’, ‘Request’, ‘Send’, ‘CF_Enfold’,1);\””;
    return $att;
    }

    Also the same – no results…

    #1139831

    Hi,

    Sorry, may be polar bear dead,bu it doesn’t work…

    Polar bear dead? That’s sad. How did you create the event goal? Are you using the latest version of the analytics library?

    // https://developers.google.com/analytics/devguides/collection/analyticsjs/

    Did you do this?

    // https://support.google.com/analytics/answer/1032415?

    You can actually remove this line because it’s unused.

    $gaq = “_gaq.push([‘_trackPageview’, ‘UA-98919545-5’]);”;
    

    Best regards,
    Ismael

    #1139885

    Hi, it works! Somebody change GA code for Tags… Very easy. Thank you!!!

    #1139961

    Hi,

    I’m glad this was resolved. If you need additional help, please let us know here in the forums.

    Best regards,
    Jordan Shannon

Viewing 15 posts - 1 through 15 (of 15 total)
  • The topic ‘Google Analytics and Yandex.Metrica goals for tracking Contact Form in Child The’ is closed to new replies.