Tagged: 

Viewing 23 posts - 1 through 23 (of 23 total)
  • Author
    Posts
  • #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 5 years, 11 months ago by lindenhof.
    #963159

    Hey 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,
    Ismael

    #963169

    Cool, 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?

    #964160

    Hi lindenhof,

    You might want to consult the Google Analytics docs for that.

    If you need further assistance please let us know.
    Best regards,
    Victoria

    #981291

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

    #982040

    Hi 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,
    Victoria

    #982043

    This 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 5 years, 10 months ago by Maw87.
    #982445

    Hi 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,
    Victoria

    #982946

    thank 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,
    Marc

    #983067

    Hi Marc,

    Is this solution not working for you?

    Best regards,
    Victoria

    #983073

    no… I think gaq.push is an old method?

    #983540

    I don’t see any of the form submittals showing up in analytics either… Any input would be apreciated

    #983700

    Hi,

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

    #984057

    So this should be the enfold-code?

    $att = "onclick=\"ga('send', 'event', ‘Kontaktformular', ‘send', ‘Kontaktformular_Startseite');\" ";

    #984502

    Hi,

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

    #984642

    for me, as also for lindenhof it doesn´t recognize any events in analytics with this code :/

    #985078

    Hi,

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

    #985083

    it´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 5 years, 9 months ago by Maw87.
    #985097

    Hi,

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

    #985176

    Screenshot of the created goal in private… but still no new goal/event reported when testing…

    #986171

    Hi,

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

    #1030373

    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.

    #1031115

    Hi,

    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

Viewing 23 posts - 1 through 23 (of 23 total)
  • The topic ‘Enfold Form Tracking’ is closed to new replies.