Last active
August 2, 2022 16:25
-
-
Save ericakfranz/4be825d54aa83b765e92ef3715e72c2d to your computer and use it in GitHub Desktop.
Trigger a conversion in OptinMonster when a specific WPForms AJAX form is submitted.
This file contains hidden or 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
// Let's trigger an OptinMonster conversion only after sucessfull WPForms submission (requires AJAX in WPForms enabled). Piece-mealed from https://wpforms.com/developers/how-to-open-a-new-link-on-form-submission/ | |
// We can use jQuery here because it's a WPForms dependency | |
jQuery( function( $ ) { | |
// Edit to change 521 to the ID of your specific WPForms form. | |
$( '#wpforms-form-521' ).on( 'wpformsAjaxSubmitSuccess', function( e ) { | |
// trigger conversion | |
om{{id}}.Listeners.convert(); | |
} ); | |
} ); | |
document.addEventListener('wpformsAjaxSubmitSuccess', function(event) { | |
// OM Conversion on any WPForms AJAX form submission | |
om{{id}}.Listeners.convert(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment