Skip to content

Instantly share code, notes, and snippets.

@ericakfranz
Last active August 2, 2022 16:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericakfranz/4be825d54aa83b765e92ef3715e72c2d to your computer and use it in GitHub Desktop.
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.
// 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