The ferromagnetic superconductor UCoGe has been investigated by high field X-ray magnetic circular dichroism (XMCD) at the U-M$_{4,5}$ and Co/Ge-K edges. The analysis of the branching ratio and XMCD at the U-M$_{4,5}$ edges reveals that the U-5$f$ electrons count is close to 3. The orbital ($sim0.70,mu_B$) and spin ($sim-0.30,mu_B$) moments of U at 2.1K and 17T (H//c) have been determined. Their ratio ($sim-2.3$) suggests a significant delocalization of the 5$f$ electron states. The similar field dependences of the local U/Co and the macroscopic magnetization indicate that the Co moment is induced by the U moment. The XMCD at the Co/Ge-K edges reveal the presence of small Co-4$p$ and Ge-4$p$ orbital moments parallel to the macroscopic magnetization. In addition, the Co-3$d$ moment is estimated to be at most of the order of 0.1$mu_B$ at 17T. Our results rule out the possibility of an unusual polarisability of the U and Co moments as well as their antiparallel coupling. We conclude that the magnetism which mediates the superconductivity in UCoGe is driven by U.