Last active
March 9, 2020 16:42
-
-
Save muZk/1fee9fdb671264589277b8e3eaa1c03f to your computer and use it in GitHub Desktop.
Ghost subscription tracker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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