Understanding homomorphism and kernels

Let $G$ be a group and $\phi$ a Homomorphism

$$\phi:G\to G'$$

Now I know that the size of the kernel tells you how many elements in $G$ map to the same element in $G'$

I couldn't find this in my book, but I have concluded the following.

$$\frac{|G|}{| \:\text{ker} \: \phi \:|} = |G'|$$

Is that true?

If $G, G^\prime$ finite and $\phi$ is surjective then this is a straightforward consequence of the First Isomorphism Theorem, which states that $G/\ker\phi\cong G^\prime$. Calculating the index on the left side by Lagrange's Theorem gives you exactly what you have.

If $\phi$ is not surjective, however, this would not hold. Instead, you must replace $G^\prime$ with $\phi(G)$, the image of $G$ under $\phi$.

This is close, but not quite right. For example, if $G^\prime$ is a proper subgroup of $H$ then $\phi$ defines a homomorphism $$\bar\phi:G\to H$$ with $\ker\bar\phi=\ker\phi$. Your result would then imply $$\lvert G^\prime\rvert=\frac{\lvert G\rvert}{\lvert\ker \phi\rvert}=\frac{\lvert G\rvert}{\lvert\ker\bar\phi\rvert}=\lvert H\rvert$$ which is absurd since $\lvert G^\prime\rvert\neq\lvert H\rvert$ in general.

To remedy the situation we must replace $G^\prime$ in your equation with $\DeclareMathOperator{Im}{Im}\Im\phi$. The formula should be $$\frac{\lvert G\rvert}{\lvert\ker\phi\rvert}=\lvert\Im \phi\rvert$$ which is a consequence of the first isomorphism theorem for groups.

It's true only if $\phi$ is surjective. Notice that we could let $\phi$ be the trivial homomorphism, sending every element of $G$ to the identity of $G'$. Then $\ker \phi = G$ and we are claiming that $$\frac{|G|}{|\ker \phi|}=1=|G'|$$ for every group $G'$. This is obviously false.

However, if $\phi$ is surjective, then, clearly, the set $S_y$ of points $x\in G$ such that $\phi(x)=y$ clearly has that $|S_y|=|\ker \phi|$, since, for any $z\in S_y$, it clearly holds that $S_y \subseteq z\ker \phi$ and that $\ker \phi \subseteq z^{-1} S_y$ where the multiplication is taken to be a coset - this holds since, if $k\in \ker\phi$ then $zk\in z\ker\phi$ and $\phi(zk)=\phi(z)\phi(k)$, which is just $y$, since $\phi(z)=y$ and $\phi(k)$ is the identity. A similar argument holds for the other expression.

Thus, each element $y$ in $G'$ is associated to the set $S_y$, which has size equal to $|\ker \phi|$. Furthermore the $S_y$ partition $G$, implying the sum of their sizes is the size of $G$. Since there are $|G'|$ distinct $S_y$ and each has the same size as the kernel, $$|G'|\cdot |\ker \phi| = |G|.$$

Let's assume all groups are finite. You observe correctly that $|\ker (\phi)|=|\phi^{-1}(g)|$, for any $g\in G'$, as long as $g$ is in the image of $\phi$, otherwise, of course $|\phi^{-1}(g)|=0$. So, the conclusion is: $|G'|=|{\rm Im}(\phi)|+|G'-{\rm Im}(\phi)|=\frac{|G|}{|\ker(\phi)|}+|G'-\Im (\phi)|$. Of course, if $\phi$ is surjective, then the second summand is $0$, and you get the formula you wrote. As noted in other answers, the same result follows easily by invoking the (first) isomorphism theorem, though (perhaps) that is a bit of an over-kill.