The Compact Muon Solenoid (CMS) detector is ideally suited to study quarkonium production in the experimentally very clean dimuon decay channel, up to considerably higher values of transverse momentum than accessible in previous experiments. The scope of this thesis is to describe in detail the measurements of the polarizations of the Υ(nS) bottomonium states and (in less detail) of the ψ(nS) charmonium states, based on a dimuon data sample collected with the CMS detector in proton-proton collisions at a center-of-mass energy of 7 TeV. Surprisingly, no significant polarizations were found in any of the studied quarkonium states, in none of the studied reference frames, nor in a frame-independent analysis. From an experimental point of view, these results, together with recent results from other experiments, clarify the confusing picture originating from previous measurements, which were plagued by experimental ambiguities and inconsistencies.The currently most favored approach to model and understand quarkonium production is non-relativistic quantum chromodynamics (NRQCD), a QCD-inspired model which allows color-octet pre-resonant quark-antiquark states to contribute to quarkonium bound state formation. The measurements obtained as a result of this work, together with other LHC measurements in the field of quarkonium production, are interpreted with an original phenomenological approach within the theoretical framework of NRQCD, guided by the observation of a few general features of the data, and corroborated by a detailed study of the quarkonium production cross section and polarization observables.This phenomenological analysis leads to a coherent picture of quarkonium production cross sections and polarizations within a simple model, dominated by one single coloroctet production mechanism. These findings provide new insight in the dynamics of heavy quarkonium production at the LHC, an important step towards a satisfactory understanding of hadron formation within the standard model.