Skip to content

Instantly share code, notes, and snippets.

@cougrimes
Created February 11, 2016 00:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cougrimes/f909ee5c4ff863936b4a to your computer and use it in GitHub Desktop.
Save cougrimes/f909ee5c4ff863936b4a to your computer and use it in GitHub Desktop.
Have long forms? See where people give up.
var parentForm = document.querySelector("[id^=mktoForm_]");
parentForm.addEventListener("focusout", doSomething, false);
var formId = document.querySelectorAll('form.mktoForm')[0].getAttribute('id');
function doSomething(e) {
if (e.target !== e.currentTarget) {
var clickedItem = e.target.id;
ga('create', 'UA-XXXXXXXX-X');
ga('send','event','Marketo Form Fillout', formId, clickedItem)
}
e.stopPropagation();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment