Kernel of homomorphism $\phi:A\to Z(A)$ where $A$ is a group

Assume $\phi:A\to Z(A)$ has its image be $Z(A)$, I'm interested in its kernel.

For any commutator $a^{-1}b^{-1}ab$,

$$\phi(a^{-1}b^{-1}ab)=\phi(a)\phi(a)^{-1}\phi( b)\phi(b)^{-1}=I.$$

So the commutator subgroup is contained in the kernel.
Is it always the kernel? Could the kernel contain elements outside of the commutator subgroup?


No, the commutator subgroup is not always the kernel of this homomorphism Consider, for example, $A = F_2$, the free group on two generators. Then nothing commutes, so $Z(F_2) = \{1\}$ and thus the only homomorphism $\phi : F_2 \to Z(F_2)$ is trivial. So, everything is in the kernel of $\phi$, which includes elements that are not commutators.