Imagine being paid to improve your favorite CMS!

It could be you! Umbraco HQ are hiring and are looking for both talents and senior developers. Wonderful workplace, friendly colleagues and competitive salary.

Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Chris Van Oort 43 posts 195 karma points
    Apr 21, 2017 @ 13:50
    Chris Van Oort
    0

    Umbraco Forms + Google Analytics Goal Tracking?

    Has anyone setup Google Analytics Goal Tracking with Umbraco Forms?

    Ideally, I'm looking for some quick code I could edit or add into place so that when forms are successfully filled out (pass validation) and are actually submitted, it send an event (or whatever is required of GA Goal Tracking) to Google.

    I tried a while back with some jQuery to attach to "onClick" & "onSubmit" and couldn't figure out how to not send the event if the form didn't actually submit (ex. form errors).

    Even better would be if there's an extension / project that I could load in to accomplish this.

    Best, Chris

  • David Morgan 2 posts 72 karma points
    Apr 21, 2017 @ 14:12
    David Morgan
    0

    The quickest solution would be to ensure the form redirects to a thank you page which does not appear on the menu and you just add the goal straight into Google Analytics?

  • Chris Van Oort 43 posts 195 karma points
    Apr 21, 2017 @ 15:36
    Chris Van Oort
    0

    That's an okay solution, but non-ideal because it involves creating another page for every form and also removes the ability to have a nice ajax form submission.

  • David Morgan 2 posts 72 karma points
    Apr 21, 2017 @ 15:49
    David Morgan
    0

    My understanding is goals needs to be tied to a URL so perhaps you are confusing Google Analytic goals with Google Analytic events. An event can be added to an onclick / onsubmit / etc but Events and Goals are very different things.

    You won't need to create another page for every form to track goals. You could make the thank you page appear based on a route like (e.g. "/page-name/thank-you", "/another-page/thank-you") then in GA you could either track these as the same goal you could specific different goals for each (or even use regular expression to group them).

    A work around if you do not want to redirect is to push a page view event straight into Google Analytics along these lines:

    gaq.push(['trackPageview', '/ajax-form-page/thank-you']);

    If you want to do a Google Analytics event then the syntax is along these lines:

    onClick="ga('send', 'event', 'Page Name', 'click', 'Form submission');

  • Chris Van Oort 43 posts 195 karma points
    Apr 21, 2017 @ 16:50
    Chris Van Oort
    0

    On Google Analytics you can setup conversion tracking goals based on events (whoo!):

    enter image description here

    My issue is that binding the "OnClick" event doesn't result in an actual conversion because all of our forms have at least one required field. So if you don't fill that form field, the click results in no info being sent to the sales team and a validation error shown to the client.

    I saw a post here: https://our.umbraco.org/forum/umbraco-pro/contour/28090-Contour-and-Google-Analytics-Goals#comment-162568

    Which describes being able to modify the onsubmit logic to fire off Google Analytics events when the onsubmit message is shown. This is now actually in "ContourForm.cshtml" which should allow me to do what I need.

Please Sign in or register to post replies

Write your reply to:

Draft