The first and second general Zagreb indices of a graph $G$, with vertex set $V$ and edge set $E$, are defined as $M_1^k = \sum_{v \in V} d(u)^k$ and $M_2^k = \sum_{uv \in E} [d(u), d(v)]^k$, where $d(v)$ is the degree of the vertex $v$ of $G$. We present combinatorial identities, relating $M_1^k$ and $M_2^k$ with counts of various subgraphs contained in the graph $G$.