Track the Submit button with Google Analytics

  • Profile Image
    Asked on July 28, 2016 at 05:03 PM

    We are trying to embed a google analytics script into the Submit button action within a form. This form is embedded on our website. 

    Are we missing something?

  • Profile Image
    Answered on July 28, 2016 at 07:19 PM

    Sorry but you won't be able to insert your GA scripts into the form. What you can do as an alternative is to grab the full source code of your form [GUIDE: How-to-get-the-Full-Source-Code-of-your-Form] and implement GA there.

    If your only aim is to track the click event of the Submit Button in GA, the general workflow would be as follows:

    1. Embed your form on your website using the full source code

    2. Locate the Submit button. In your form it would be:

    <button id="input_2" type="submit" class="form-submit-button">Submit</button>

    3. Add an onclick event to your button and place your GA tracking code there:

    <button id="input_2" type="submit" class="form-submit-button" onclick="place your GA logic here">Submit</button>

    Note that you may need to hire a developer to set this up for you.

    On the other hand, there's a rather easier way to track how your form performs by using our native Form Analytics feature. I highly recommend you go to this page to learn more about it and give it a spin. Here's how you can access Form Analytics.

    Lastly, we also have a widget for GA To add a widget to your form, just follow this guide [GUIDE: How-to-Add-a-Widget-to-your-Form] This only requires you to add your Universal Tracking ID and an optional feature for Cross Domain Auto Linking

    Hope these helped!