Do action only on certain front end pages?

to test if you are on specific page, you just need to test the identifier like that :

add_action("wp_head", function () {

    $idPageToTest = 32867;


    if (    isset($GLOBALS["post"])
        &&  ($GLOBALS["post"]->ID === $idPageToTest)
    ) {
        echo "We are on page $idPageToTest.";
    }


}