# Never Send the Referrer From Checkout and Account Pages

> Sends a strict no-referrer policy on the WooCommerce checkout, order received and account pages, so order keys and other private URL details are never passed to third-party scripts or sites linked from there.

- Type: PHP
- Runs: Frontend only
- Category: [Privacy & Cookies](https://wpide.com/library/category/privacy/)
- Requires: WooCommerce
- Tags: woocommerce, referrer, checkout
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/privacy-no-referrer-on-checkout/

## Code

```php
add_action( 'template_redirect', function () {
    if ( ! function_exists( 'is_checkout' ) || headers_sent() ) {
        return;
    }

    if ( is_checkout() || is_account_page() || is_wc_endpoint_url( 'order-received' ) ) {
        header( 'Referrer-Policy: no-referrer' );
        add_action( 'wp_head', function () {
            echo '<meta name="referrer" content="no-referrer">' . "\n";
        }, 0 );
    }
}, 20 );
```

## Notes

Payment gateways that redirect off-site are not affected; they do not rely on the referrer.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Never Send the Referrer From Checkout and Account Pages" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
