Skip to content

Instantly share code, notes, and snippets.

@mahbubme
Last active September 21, 2020 15:14
Show Gist options
  • Save mahbubme/920506498ed964cce6a6a1778141ccda to your computer and use it in GitHub Desktop.
Save mahbubme/920506498ed964cce6a6a1778141ccda to your computer and use it in GitHub Desktop.
Track MonsterInsights forms
const submitButtons = document.querySelectorAll("input[type='submit']");
submitButtons.forEach( formButton => {
formButton.addEventListener(
"click",
function (evt) {
__gaTracker(
"send",
"event",
"form",
"conversion",
formButton.form.id,
1
);
},
false
);
});
jQuery( function ( $ ) {
$( '.play-button' ).click( function () {
console.log('Form viewed');
__gaTracker( 'send', {
hitType: 'event',
eventCategory: 'form',
eventAction: 'impression',
eventLabel: 'wpforms-form-493',
eventValue: 1,
nonInteraction: 1
} );
} );
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment