In the affine case, let $X=Spec A$, $Y=Spec B$, and $Z=Spec R$. If you have morphisms $f:Z\rightarrow X$ coming from $\phi:A\rightarrow R$ and $g:Z\rightarrow Y$ coming from $\psi: B\rightarrow R$, then the coproduct $X \sqcup_{Z} Y$ of $X$ and $Y$ along $Z$ is given by $Spec D$, where
$D=A\oplus_{\phi , R , \psi} B:=$ { $(a,b) \in A\oplus B | \phi (a)= \psi (b) $ } .