Search code examples
formsgoogle-analyticsevent-tracking

How To Event track a particular event with Google Analytics?


I don't have a separate thank you/confirmation page to track Goal Conversions from a particular landing page. So, I need to Event track a "Submit Form" button of the landing page to count number of Form Submission as Goal Conversions from that page.

How to Event Track the "Submit Form" button so that it shows on Goal Completions pages when someone submits form.


Solution

  • Here you will find how to create a goal that is based on a specific Event instead of a page view:

    https://support.google.com/analytics/answer/1032415?hl=en#goal_types

    To dispatch the Event expected by the Goal, i will recommend you to use this jQuery plugin (i'm the author) which was built for easily setup Event Tracking for Google Analytics:

    https://github.com/DiegoZoracKy/google-analytics-event-tracking.

    The result of your code will be something like this:

    $.googleAnalyticsEventTracking({
        targetSelector: '#id-of-the-form', // it can be any jQuery selector
        events: {
            eventType: 'submit',
            gaEventData: {
                category: 'Form', // The same as you will set on the Goal setup
                action: 'Sent', // The same as you will set on the Goal setup
                label: 'Sign Up' // The same as you will set on the Goal setup
            }
        }
    });