Differential measurements of Z and γ bosons produced with jets at the CMS experiment