Virial (aka scaling) identities are integral identities that are useful for a variety of purposes in non-linear field theories, including establishing no-go theorems for solitonic and black hole solutions, as well as for checking the accuracy of numerical solutions. In this paper, we provide a pedagogical rationale for the derivation of such integral identities, starting from the standard variational treatment of particle mechanics. In the framework of one-dimensional (1D) effective actions, the treatment presented here yields a set of useful formulas for computing virial identities in any field theory. Then, we propose that a complete treatment of virial identities in relativistic gravity must take into account the appropriate boundary term. For General Relativity this is the Gibbons-Hawking-York boundary term. We test and confirm this proposal with concrete examples. Our analysis here is restricted to spherically symmetric configurations, which yield 1D effective actions (leaving higher-D effective actions and in particular the axially symmetric case to a companion paper). In this case, we show that there is a particular gauge choice, $i.e.$ a choice of coordinates and parameterizing metric functions, that simplifies the computation of virial identities in General Relativity, making both the Einstein-Hilbert action and the Gibbons-Hawking-York boundary term non-contributing. Under this choice, the virial identity results exclusively from the matter action. For generic gauge choices, however, this is not the case.