that depends on the other code on the page.
if you have a quick cart on the page that contains a button to direct to the view cart or checkout page, or you have an add to cart button on the page that redirects to the view cart page after pressing it then yes, that code is needed on the page.
I doubt it would be needed on every page, though.