Toggle menu

Google Analytics Event

The Google Analytics Event field can send an event to Google that can be tracked in your analytics account. The field can be configured to send an event when a form is displayed, when a field has its value changed, or when validation errors occur. It cannot be used to send an event when a form's submit button is pressed. For event tracking to work your site must already be using Google Analytics and the standard tracking snippet must be present on the form page.

The event sent to Google will be the default values set in the field. You can trigger this using setFieldValue() from another field's handler if the event field has the property "Value Events" set to true.

The field also supports two custom functions:

  • sendDefaultEvent(label, value) will send an event to Google Analytics with the category and action specified in the field properties. The value parameter is optional.
  • sendCustomEvent(category, action, label, value) will send an arbitrary event to Google Analytics. The value parameter is optional.

Properties

LabelDescriptionType Name
GA CategoryThe Google Analytics event category. A category is the name used to group the things you want to trackCATEGORY
GA ActionThe Google Analytics event action. Typically the action parameter is used to name the type of event or interaction being tracked in a particular categoryACTION
GA LabelThe Google Analytics label. Labels are optionalLABEL
GA ValueThe Google Analytics value. As per Google, values must be integersVALUE
Display EventsSend the event to Google Analytics when the page is displayedSENDONRENDER
Value EventsSend an event to Google Analytics when this field's value is updated. The value of the field can be set with the Helper library setFieldValue() function. If the field has the property "Value Events" set to true, then the act of setting the value will automatically send the event to Google AnalyticsSENDONUPDATEVALUE
Validation EventsIf a field on the form fails its validation, an event will automatically be sent to Google if 'Validation Events' is set to true. This event will supply GA Action of 'Validation Error' rather than the 'GA Action' defined above, and its label will be set as the error message. If the 'Validation Event Values' setting (below) is also set to true, the invalid field's value will be sent as the event's value. Otherwise, no value will be sentSENDONVALIDATIONERR
Validation Event ValuesIf 'Validation Events' is set to true, then an invalid field's value will be included in a validation error event if this 'Validation Event Values' setting is also set to true. Otherwise, no value will be sentSENDVALIDATIONVALUE
DocumentationAdd documentation to your field to help explain any complex functionality to future users. You might include information on what the field does and how it relates to other fields on the form. Notes added here are only ever visible in the Forms Designer, they can be searched for, viewed and downloaded from the action panel. See Common Field Properties for an exampleDOCUMENTATION

Example

This form has a checkbox, a radio group and a single Google Analytics Event field called GAEVENT. When the values of these fields change, an event is sent to Google Analytics.

If you're using Chrome, open the network tab in the browser developer tools to see the events being triggered.

In this screenshot you can see events in Google Analytics. We've already drilled down past the category level so you can see the action and label values.

Google Analytics Events
 

The Google Analytics Event field has the following default values:

PropertyValue
GA CategoryExample Forms
GA ActionBox Ticking
GA LabelThe box has been ticked or unticked

The checkbox has the following handler, which triggers the hidden event field, sending the default values to Google.

function (helper, fieldName, value, valid, eventName) {
    if (eventName == 'CHANGE' && valid) {
        helper.setFieldValue('GAEVENT','');
    }
}

The radio buttons invoke the event field's custom function  sendCustomEvent(category, action, label, value), which allows the information sent to Google to by generated dynamically.

This handler has been added to the radio button field:

function(helper, fieldName, value, valid, eventName) {
    if (value == 'Yes') {
        helper.invokeCustomFieldFn('GAEVENT', 'sendCustomEvent', 'Example Forms', 'Radio Button Change', 'Yes');
    } else if (value == 'No') {
        helper.invokeCustomFieldFn('GAEVENT', 'sendCustomEvent', 'Example Forms', 'Radio Button Change', 'No');
    }
}

Share this page

Facebook icon Twitter icon email icon

Print

print icon