-
AuthorPosts
-
June 1, 2017 at 10:04 am #802442
Hi,
I need to add the redirect script below to the Enfold child theme:<script>
document.addEventListener( ‘wpcf7mailsent’, function( event ) {
location = ‘http://example.com/’;
}, false );
</script>Where have I to put it?
Thanks.Regards,
PieroJune 1, 2017 at 10:17 am #802450Morning
You could put the code in the google analytics section under Theme Options > Google Services.
I’ve used that section to put marketing automation tracking codes and google codes and they work fine.Or you could add a function to the functions.php
function add_custom_target(){ ?> <script> document.addEventListener( ‘wpcf7mailsent’, function( event ) { location = ‘http://example.com/’; }, false ); </script> <?php } add_action('wp_footer', 'add_custom_target');
Be very careful with the last option as any errors in functions.php could throw up a 500 internal error and you’ll need ftp or cPanel access to reverse the changes.
Try the first as that is a safe option :) Once done right click on any page of your site and click view page source. Search the source code for the script to see if it has worked.
Hope that helps
TJ
June 1, 2017 at 12:06 pm #802498Hi tjswarbs78,
Thanks for helping out :)
@edisai2014: Please try to use the code above, that should work :)Best regards,
NikkoJune 1, 2017 at 4:47 pm #802653Hi
thank you for your advice.
Unfortunately it doesn’t work.
The page indicated in the script is not loaded.
I put the function in child theme functions.php.
Before I tried in Google services but I did not see the script in view page source.Any idea?
ThanksPiero
June 2, 2017 at 10:47 am #802927Hi,
Did you paste just the script in Google services or the whole function.
If pasting to Google services just use<script> document.addEventListener( ‘wpcf7mailsent’, function( event ) { location = ‘http://example.com/’; }, false ); </script>
That’s the only reason I can think as to why it isn’t working. The code should be right at the bottom before the </body> tag
Hope that helps
TJ
June 2, 2017 at 1:25 pm #803000Hi,
@tjswarbs78: Thanks for helping out :)
@edisai2014: if that doesn’t help, can you try to us temporary admin access? so we can check further. Just place the details in private content when you reply so it is only visible to the moderators.Best regards,
NikkoJuly 24, 2017 at 9:26 pm #829204I have a similar issue/question. But I have 2 CF7 on my website…
and I want to apply this to each one (each opening another window):<script>
document.addEventListener( ‘wpcf7mailsent’, function( event ) {
location = ‘http://example.com/’;
}, false );
</script>How do I do that and not have the script go to the same page on all forms?
Thanks
DJuly 25, 2017 at 5:59 am #829373Hi D,
Try to ask the support of contact form 7, I think they would be able to help better regarding it :)
Best regards,
Nikko -
AuthorPosts
- You must be logged in to reply to this topic.