Tagged: CONTACT FORM, google analytics
-
AuthorPosts
-
November 27, 2018 at 10:58 am #1037950
Hi,
We want to track an user interaction as well, regarding when the form is submitted – So the click on the send-button itself. We created in GoogleAnalytics a goal as well. The contact form is displaying a message that the form has been sent, so it is not directing to a thankyou-page (which can be set up in Analytics’ goal as well).I tried “onsubmit” instead onclick as well but during testing (even in inkognito mode or different pc ) it seems not to track.
I inserted the following snippet into the child’s theme 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){
$gaq = “_gaq.push([‘_trackPageview’, ‘UA-111111111-1’]);\””;
$att = “onclick=\”ga(‘send’, ‘event’, ‘Senden’, ‘Kontakt’, ‘Senden’);\” “;
return $att;
}PS: UA-111111111-1 just represents the ID
PPS: I love your theme – already bought it several times.Thanks in Advance :)
November 27, 2018 at 9:27 pm #1038210Hey binary_magenta,
Make sure your quotes are fine.
Best regards,
VictoriaNovember 28, 2018 at 11:12 am #1038413Hi Victoria,
I tried: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-1xxxxxxxx-1']);"; $att = "onclick=\"ga('send', 'event', 'Senden', 'Kontakt', 'Senden');\""; return $att; }
but Analytics does not pick up sth during testing :(.
Best regards.
- This reply was modified 6 years ago by binary_magenta.
November 28, 2018 at 12:48 pm #1038475Hi binary_magenta,
Best regards,
VictoriaNovember 28, 2018 at 4:54 pm #1038589Hi Victoria,
I tried the snippet form your post from 2017 as well but it seems the ga() command queue requires a ‘send’ command for the “event” hit type instead, regarding analytics.js.Additionally I defined a new goal: https://cl.ly/b5ee30edb73d and altered the snippet accordingly:
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-123456789-1']);";
$att = "onclick=\"ga('send', 'event', 'Form Submit', 'Senden', 'Contact Form Submit',1);\"";
return $att;
}
There is still no conversion showing up. I think I stumbled upon a good reply of Ismael regarding tracking in an other thread some days ago but I somehow cannot find it again :/.
I also tried a plugin which sounded promising… but still no reaction.
Thanks a lot in advance.
December 3, 2018 at 7:02 am #1040145Hi,
Thanks for the update.
The event is being sent properly. (see private field)
Please try to check it again today. It may take a while to propagate to or be seen in your google analytics console.
Best regards,
IsmaelDecember 3, 2018 at 10:22 am #1040201It’s working! :D I just needed some patience here – Thank you all for your help!
Best regards,
CRDecember 3, 2018 at 3:03 pm #1040337Hi CR,
Great, glad you got it working :-)
Please let us know if you should need any further help on the topic or if we can close it.
Best regards,
RikardJanuary 9, 2019 at 11:29 am #1051729You can close it.
Thank you for your support! -
AuthorPosts
- You must be logged in to reply to this topic.