Public opinion absolutely does influence foreign policy, especially if it's a salient enough issue and there are no vital foreign policy interests at stake (and there aren't for most Western countries).
The main reason the EU doesn't have the most severe sanctions on Israel right now is because of Germany. And it's not because Germany has vital interests in that part of the world. A lesser reason is because of bipartisan support for Israel in the US. But Israel is becoming toxic for the Democratic Party. We're probably 1-2 election cycles away from a pro-Israeli politician being unable to win a Democratic primary in much of the country.