Created
July 9, 2018 21:15
-
-
Save timersys/615d22c5a61c45182734460cb7c40527 to your computer and use it in GitHub Desktop.
Open popup after submitting contact form 7
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
<?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