A technique for analytical calculation of observables in lattice gauge theories