  We develop the method of Ramsey spectroscopy with the use of an additional
field compensating the frequency shifts of clock optical transitions. This
method in combination with the method of magnetically induced excitation of
strongly forbidden transitions $^1S_0$$\to$$^3P_0$ [A.V. Taichenachev, et al.,
Phys. Rev. Lett. {\bf 96}, 083001 (2006)] allows the practically complete
compensation (down to the fractional level below 10$^{-17}$ with respect to the
unperturbed clock frequency) of field shifts of various origin for even
isotopes of alkaline-earth-like atoms confined to an optical lattice at magic
wavelength (lattice-based atomic clocks). Apart from this, the new method can
be used in the two-photon Doppler-free Ramsey spectroscopy of other forbidden
optical transitions (for example, $^1S_0$$\to$$^1S_0$ and $^1S_0$$\to$$^1D_2$)
and other atoms. This opens perspectives for development of principally new
variants of primary optical frequency standards based on free atoms. As a
whole, the method of the shift-compensating field is distinguished by
simplicity and high efficiency, and it can be applied for any transitions in
any atoms and ions.
