Skip to content

Instantly share code, notes, and snippets.

@jrevillini
Forked from techjewel/event-for-all-forms.js
Created March 4, 2025 21:45
Show Gist options
  • Save jrevillini/670475eeff0e20de5063bf53eea15833 to your computer and use it in GitHub Desktop.
Save jrevillini/670475eeff0e20de5063bf53eea15833 to your computer and use it in GitHub Desktop.
Track Google Analytics event for all fluent forms in your site
(function($){
if(typeof gtag != 'function') {
return;
}
var fluentForms = $('form.frm-fluent-form');
fluentForms.each(function() {
var $form = $(this);
var formId = $form.attr('data-form_id');
gtag('event', 'ViewForm', {
'event_category': 'FluentForms',
'event_label': 'View Form',
'form_id': formId
});
$form.on('fluentform_submission_success', function() {
gtag('event', 'FormSubmission', {
'event_category': 'FluentForms',
'event_label': 'Form Submitted',
'form_id': formId
});
});
});
}(jQuery));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment