Tagged: Analytics
-
AuthorPosts
-
May 25, 2018 at 5:44 pm #962290
Hello,
I’d like to track when users use contact forms (that’s a conversion in its own right) – tried following the instructions on https://kriesi.at/documentation/enfold/contact-form/#add-on-click-event-to-the-contact-form-submit-button-
, and added the code to my functions.php, but it gave me a 505 error when I tried to open the website.Here’s the code I added to my child theme’s 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=”_gaq.push([‘_trackPageview’, ‘UA-1111111-1’]);””;
return $att;
}(UA-1111111-1 being my tracking ID.)
- This topic was modified 6 years, 5 months ago by lindenhof.
May 28, 2018 at 1:17 pm #963159Hey lindenhof,
Thank you for using Enfold.
There’s a minor syntax error. Please replace the code with this one.
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', '/VP/XXX/XXX']);"; $att = "onclick='{$gaq}'"; return $att; }
Replace the tracking ID.
Best regards,
IsmaelMay 28, 2018 at 1:24 pm #963169Cool, thanks a lot! There’s no error now.
I know this is not a directly theme-related question, but where do the contact form submittals show up in Google Analytics? How can I assign a conversion value to a submittal?
May 30, 2018 at 12:05 pm #964160Hi lindenhof,
You might want to consult the Google Analytics docs for that.
If you need further assistance please let us know.
Best regards,
VictoriaJuly 4, 2018 at 4:59 pm #981291hi,
may you can change this syntax error in the docu? I´ve got the same error after using the code out of your docu!thank you
July 6, 2018 at 1:26 pm #982040Hi Maw87,
What error are you getting?
Can you give us temporary admin access to your website in the private content box below, so that we can have a closer look?
Best regards,
VictoriaJuly 6, 2018 at 1:29 pm #982043This is the error:
Parse error: syntax error, unexpected '_gaq' (T_STRING) in /var/www/vhosts/7/1245332/webspace/httpdocs/wp-content/themes/enfold-child/functions.php on line 50
Line 50 is this line:
$att = "onclick="_gaq.push(['_trackPageview', 'UA-5689302-12']);"";
- This reply was modified 6 years, 4 months ago by Maw87.
July 7, 2018 at 1:34 pm #982445Hi Maw87,
Thank you, you need to change the double quotes to single ones or put a slash in front of them.
$att = "onclick=\"_gaq.push(['_trackPageview', 'UA-5689302-12']);\"";
or
$att = "onclick='_gaq.push(['_trackPageview', 'UA-5689302-12']);'";
If you need further assistance please let us know.
Best regards,
VictoriaJuly 9, 2018 at 7:48 am #982946thank you, maybe you want to change this in the docu as well?
I´m using the new analytics tracking code – how to track contact form in 2018?
Best,
MarcJuly 9, 2018 at 12:38 pm #983067July 9, 2018 at 12:43 pm #983073no… I think gaq.push is an old method?
July 10, 2018 at 9:10 am #983540I don’t see any of the form submittals showing up in analytics either… Any input would be apreciated
July 10, 2018 at 2:43 pm #983700Hi,
You need to add the latest analytics tracking snippet first.
// https://developers.google.com/analytics/devguides/collection/analyticsjs/
Implement the page tracking after enabling the analytics.js file.
// https://developers.google.com/analytics/devguides/collection/analyticsjs/pages
You can also create goals and trigger an analytics event based on a specific action (ex: ‘click’).
// https://developers.google.com/analytics/devguides/collection/analyticsjs/events
Best regards,
IsmaelJuly 11, 2018 at 8:09 am #984057So this should be the enfold-code?
$att = "onclick=\"ga('send', 'event', ‘Kontaktformular', ‘send', ‘Kontaktformular_Startseite');\" ";
July 12, 2018 at 6:02 am #984502Hi,
Yes, that is the code that you have to use when you created a goal in the analytics dashboard. Did you create one?
// https://support.google.com/analytics/answer/1032415?hl=en
Best regards,
IsmaelJuly 12, 2018 at 11:53 am #984642for me, as also for lindenhof it doesn´t recognize any events in analytics with this code :/
July 13, 2018 at 10:11 am #985078Hi,
Where did you add the contact form? We would like to check if the onclick attribute was actually added in the contact form button. Please provide a screenshot of the analytics event goal.
Best regards,
IsmaelJuly 13, 2018 at 10:19 am #985083it´s the contact form at the bottom of the page at “#contact”.
I didn´t create an event goal because normally it should be reported in Events although no goal for this is defined?!best,
Marc- This reply was modified 6 years, 4 months ago by Maw87.
July 13, 2018 at 10:44 am #985097Hi,
I didn´t create an event goal because normally it should be reported in Events although no goal for this is defined?!
That will only work for tracking page views. You have to create an event goal if you want to track user interaction such as submitting a form.
Best regards,
IsmaelJuly 13, 2018 at 2:43 pm #985176Screenshot of the created goal in private… but still no new goal/event reported when testing…
July 17, 2018 at 1:52 am #986171Hi,
Thanks for the update. Can I have access to your gmail account? I would like to test it.
Is it working when you set the contact form to redirect to another page instead of displaying a message that the form was sent?Best regards,
IsmaelNovember 6, 2018 at 12:59 pm #1030373Hi,
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.- This reply was modified 6 years ago by binary_magenta.
November 8, 2018 at 6:01 am #1031115Hi,
Which type of google analytics are you using?
// https://developers.google.com/analytics/devguides/collection/analyticsjs/
This line in your code is actually invalid or is not use.
$gaq = “_gaq.push([‘_trackPageview’, ‘UA-111111111-1’]);\””;
It just sets the $gaq variable but it’s not use anywhere. Please open a new thread with the site url and the login credentials.
Best regards,
Ismael -
AuthorPosts
- The topic ‘Enfold Form Tracking’ is closed to new replies.