Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #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 :)

    #1038210

    Hey binary_magenta,

    Make sure your quotes are fine.

    Best regards,
    Victoria

    #1038413

    Hi 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.

    #1038475

    Hi binary_magenta,

    Best regards,
    Victoria

    #1038589

    Hi 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.

    #1040145

    Hi,

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

    #1040201

    It’s working! :D I just needed some patience here – Thank you all for your help!
    Best regards,
    CR

    #1040337

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

    #1051729

    You can close it.
    Thank you for your support!

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.