Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Open popup after submitting contact form 7
<?php
// Print javascript code in the footer of the site to trigger the popup upon form submission
add_action('wp_footer', 'add_popups_trigger_code',150 );
function add_popups_trigger_code(){
// show code on certain page, comment out to print code on every page
if( ! is_page('520') )
return;
?>
<script>
document.addEventListener( 'wpcf7mailsent', function( event ) {
if ( '531' == event.detail.contactFormId ) { // Change 123 to the ID of the form
SPU.show( 529 ); // change 143 to the ID of the popup
SPU.hide( 120 ); // hide another popup
SPU.track( 529, false );//track an impression , if you set to true you track a conversion
}
}, false );
</script>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment