[Contact form7] How to transition to the Thank you page

Code

function.php

add_action( 'wp_footer', 'send_page' );
function send_page() {
if( get_the_ID() == '[form page ID]' ) {
echo <<< EOD
<script>
document.addEventListener( 'wpcf7mailsent', function( event ) {
location = '[Thank you page URL]';
}, false );
</script>
EOD;
}
}

Related article