Phase transition analysis in Z2 and U(1) lattice gauge theories