Home Forums WoodMart support forum How to add custom script to the thank you page

How to add custom script to the thank you page

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #597841

    metrocomdev
    Participant

    Hi,
    I’m currently using Facebook Pixel to track traffic on my website. I was instructed to add a script to the header of the thank you page after checkout. However, my website doesn’t have a physical “Thank You” page—it’s just a link like this:

    /checkout/order-received/22942/?key=wc_order_1SjsyhGBZRPh5

    Could you please guide me on how to insert the script into the thank you page?

    #597842

    metrocomdev
    Participant

    I added the following code to the functions.php file. I’m unsure if this is the correct approach, or if there might be a better solution you can suggest:
    function add_facebook_pixel_script() {
    if ( is_order_received_page() ) {
    ?>
    <!– Meta Pixel Code –>
    script here
    <!– End Meta Pixel Code –>

    <?php
    }
    }
    add_action(‘wp_head’, ‘add_facebook_pixel_script’);

    #598015

    Hello,

    The Most Easy way is to add it using a free plugin https://wordpress.org/plugins/insert-headers-and-footers/

    If you want to edit the header.php file directly then you need to copy the header.php file from the main theme to the child theme and then try adding the code in it.

    You can read the following article for further help:
    https://www.wpbeginner.com/plugins/how-to-add-header-and-footer-code-in-wordpress/

    Best Regards.

Viewing 3 posts - 1 through 3 (of 3 total)