Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #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/&#8217;;
    }, false );
    </script>

    Where have I to put it?
    Thanks.

    Regards,
    Piero

    #802450

    Morning

    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

    #802498

    Hi tjswarbs78,

    Thanks for helping out :)


    @edisai2014
    : Please try to use the code above, that should work :)

    Best regards,
    Nikko

    #802653

    Hi
    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?
    Thanks

    Piero

    #802927

    Hi,

    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

    #803000

    Hi,


    @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,
    Nikko

    #829204

    I 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/&#8217;;
    }, false );
    </script>

    How do I do that and not have the script go to the same page on all forms?
    Thanks
    D

    #829373

    Hi D,

    Try to ask the support of contact form 7, I think they would be able to help better regarding it :)

    Best regards,
    Nikko

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.