In this article, we study a class of groups which are commensurable with a direct product of the discrete Heisenberg group and a free abelian group, or a free abelian group by using zeta functions of groups defined by Grunewald, Segal, and Smith as generating functions of the number of subgroups of given index n. We will show that zeta functions determine their isomorphism classes for groups belonging to the above class