  We describe the complex multiplication (CM) values of modular functions for
$\Gamma_0(N)$ whose divisor is given by a linear combination of Heegner
divisors in terms of special cycles on the stack of CM elliptic curves. In
particular, our results apply to Borcherds products of weight $0$ for
$\Gamma_0(N)$. By working out explicit formulas for the special cycles, we
obtain the prime ideal factorizations of such CM values.
