For arbitrary level $N$, we relate the generating series of codimension $2$ special cycles on $X_0(N)$ to the derivatives of a genus $2$ Eisenstein series, especially the singular terms of both sides. On the analytic side, we use difference formulas of local densities to relate the singular Fourier coefficients of the genus $2$ Eisenstein series to the nonsingular Fourier coefficients of a genus $1$ Eisenstein series. On the geometric side, we study the reduction of cusps to compute the divisor class of the Hodge bundle and the heights of special divisors. When $N$ is square-free, this gives a different proof of the main results in the works of Du, Yang and Sankaran, Shi, and Yang.