Suppose that $S$ follows a geometric brownian motion: $$ dS(u) = r S(u)du + S(u)\sigma(u,S(u))dW(u) , $$ with $r$ a deterministic constant, and let the process $Z$ be defined by: $$ Z(t) = \int_0^t g(u, S(u))du, $$ where $g$ is a deterministic function. I would like to find the stochastic process followed by $Z$.
Following the idea shown here, I compute: $$ S(t) = S(0) + \int_0^t \alpha(u,S(u))S(u)du + \int_0^t \sigma(u,S(u))S(u)dW(u), $$ and for $Z$: $$ Z(t) = \int_0^t g(u, S(0)+ \int_0^u \alpha(v,S(v))S(v)dv + \int_0^u\sigma(v,S(v))S(v)dW(v))du, $$ where all the integrals are deterministic, except $\int_0^u \sigma(v,S(v))S(v)dW(v)$ which is an Ito integral. At this point, I am not sure on how to differentiate appropriately the equation above in order to get the stochastic process for $Z$.
Naively, I would just take advantage of Ito's lemma to write: $$ dZ(t) = \left(g(t, S(t)) + \int_0^t g_S(u,S(u))du\cdot \alpha(t,S(t))S(t) + \frac12 \int_0^t g_{SS}(u,S(u))du \cdot\sigma^2(t,S(t))S(t)^2 \right)dt + \int_0^t g_S(u,S(u))du \cdot\sigma(t,S(t))S(t)dW(t), $$ but this does not seem to lead to the correct answer.
What is the satisfactory way of formalising the stochastic process for $Z$?