Skip to content

Instantly share code, notes, and snippets.

@muZk
Last active March 9, 2020 16:42
Show Gist options
  • Save muZk/1fee9fdb671264589277b8e3eaa1c03f to your computer and use it in GitHub Desktop.
Save muZk/1fee9fdb671264589277b8e3eaa1c03f to your computer and use it in GitHub Desktop.
Ghost subscription tracker
if ("MutationObserver" in window) {
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
var form = mutation.target;
if (form.classList.contains('success') && mutation.oldValue != '') {
// TRACK HERE
}
});
});
var subscriptionForms = document.querySelectorAll('form[data-members-form="subscribe"]');
subscriptionForms.forEach(function (form) {
observer.observe(form, {
attributes: true,
attributeOldValue: true,
attributeFilter: ['class']
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment