A measurement of the phase difference between the short- and long-distance contributions to the decay is performed by analysing the dimuon mass distribution. The analysis is based on pp collision data corresponding to an integrated luminosity of 3 collected by the LHCb experiment in 2011 and 2012. The long-distance contribution to the decay is modelled as a sum of relativistic Breit-Wigner amplitudes representing different vector meson resonances decaying to muon pairs, each with their own magnitude and phase. The measured phases of the and resonances are such that the interference with the short-distance component in dimuon mass regions far from their pole masses is small. In addition, constraints are placed on the Wilson coefficients, and , and the branching fraction of the short-distance component is measured.