There is a Weyl integration formula that deals with this problem. $\newcommand{\bR}{\mathbb{R}}$ Denote by $G_n$ the space of symmetric $n\times n$ real matrices. It states that for any $O(n)$-invariant $h:G_n\to \bR$ we have
$$ (2\pi)^{-n(n+1)/4} \int_{G_n} h(A) e^{-({\rm tr} A^2)/4} dA $$$$ (2\pi)^{-\frac{n(n+1)}{4}} \int_{G_n} h(A) e^{-\frac{{\rm tr} A^2}{4}} dA $$
$$ =\frac{1}{Z_n}\int_{\mathbb{R}^n} h(\lambda_1,\dotsc, \lambda_n) e^{-\frac{1}{4} \sum_{j=1}^n \lambda_j^2} {\prod} |\lambda_j-\lambda_k| d\lambda_1\cdots d\lambda_n$$$$ =\frac{1}{Z_n}\int_{\mathbb{R}^n} h(\lambda_1,\dotsc, \lambda_n) e^{-\frac{1}{4} \sum_{j=1}^n \lambda_j^2} \; {\prod_{j<k}} |\lambda_j-\lambda_k| \; d\lambda_1\cdots d\lambda_n$$
where the product is taken over $j< k$ and
$$Z_n =2^{\frac{n}{2}}n! \prod_{j=1}^n \Gamma(\frac{j}{2}).$$
(Sorry for the typesetting clumsiness. There seems to be problem with MathJax.)
Now, use this formula for
$$ h(A)= f(g(A)) e^{\frac{{\rm tr} A^2}{4}}. $$$$ h(A)= f(g(A))\, e^{\frac{{\rm tr} A^2}{4}}. $$
For more details see Appendix BC of this paper and the references therein.