If we have a nonconstant map of nonsingular curves $\varphi:X\rightarrow Y$, then Hartshorne defines a map $\varphi^* Div(Y)\rightarrow Div(X)$ using the fact that codimension one irreducibles are just points, and looking at $\mathcal{O}_{Y,f(p)} \rightarrow \mathcal{O}_{X,p}$. My question is if we don't have a nice map of curves, what conditions can we put on the morphism so that we may pull divisors back? Clearly it's not true in general, since we can take a constant map and then topologically the inverse image doesn't even have the right codim.

Thinking about this in terms of Cartier divisors (and assuming the schemes are integral), it seems like we just need a way to transport functions in $K(Y)$ to functions in $K(X)$. If $\varphi$ is dominant, then we'll get such a map. Is this sufficient? Also is there something we can say when $\varphi$ is not dominant? Something like we have a way to map divisors with support on $\overline{\varphi(X)}$ to divisors on $X$?