Display Script in Header When URL Variable Present

URL variables like that are stored in the $_GET variable. You can check the existence and value of one like this:

add_action(
    'wp_head',
    function() {
        if ( isset( $_GET['feedback'] ) && 'yes' === $_GET['feedback'] ) {
            ?>
            <script>
                alert( 'Hello, world!' );
            </script>
            <?php
        }
    }
);

The check for isset() is necessary as checking $_GET['feedback'] alone will throw an error if it’s not present in the URL at all.