Tagged: child theme, CONTACT FORM, google analytics
-
AuthorPosts
-
June 5, 2015 at 1:07 pm #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”.June 5, 2015 at 10:39 pm #455332Hi 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, 6 months ago by Elliott.
January 26, 2018 at 1:17 pm #903368it is fantastically uncomfortable. is it not possible to make a field in the component settings, to enter a javascript event??
January 29, 2018 at 10:06 pm #904467Hi,
No, there is no visual way for that
Some things, do require coding to be achieved.Best regards,
BasilisJanuary 26, 2019 at 6:02 am #1059014Hi, few days ago new metrika start to work and new syntaxis:
https://yandex.com/support/metrica/objects/reachgoal.htmlI 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?
January 28, 2019 at 11:25 pm #1059831Hi,
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,
BasilisFebruary 3, 2019 at 5:12 pm #1062295Problem 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)
February 7, 2019 at 7:07 am #1063869Hi,
Forget my previous reply. You have to replace the wrapper of the “Order” value with single quotes.
return true; value='Order';\”
Best regards,
IsmaelFebruary 7, 2019 at 7:14 am #1063872Hi,
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,
IsmaelFebruary 8, 2019 at 12:22 pm #1064554Hello,
Thank you very much for your great work!
February 9, 2019 at 7:35 am #1064877Hi KidLoop,
Great, I’m glad we could help. Please let us know if you should need any further help on the topic.
Best regards,
RikardSeptember 18, 2019 at 10:24 am #1139370Hello,
Sorry, may be polar bear dead,bu it doesn’t work…
I made a GA goal:
Request
Send
CF_Enfold
1And 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…
September 19, 2019 at 10:14 am #1139831Hi,
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,
IsmaelSeptember 19, 2019 at 12:44 pm #1139885Hi, it works! Somebody change GA code for Tags… Very easy. Thank you!!!
September 19, 2019 at 4:21 pm #1139961Hi,
I’m glad this was resolved. If you need additional help, please let us know here in the forums.
Best regards,
Jordan Shannon -
AuthorPosts
- The topic ‘Google Analytics and Yandex.Metrica goals for tracking Contact Form in Child The’ is closed to new replies.