Chronic pain associates with various sleep problems. Patients with complex regional pain syndrome (CRPS) often report impaired sleep, but objective measurements of sleep in CRPS patients are scarce. Neuromodulation with repetitive transcranial magnetic stimulation (rTMS) can alleviate pain and improve sleep. Secondary somatosensory cortex (S2) is a possible rTMS target for the treatment of chronic pain, but the effect of S2-targeted rTMS on sleep is unknown. This randomized, sham-controlled trial assessed the effect of S2-targeted rTMS on sleep in patients with CRPS. Patients (n=31) received either S2-targeted rTMS (10Hz) or sham stimulation for 3 weeks. The effect of treatment on sleep was assessed with validated questionnaires, with a sleep and pain diary, and with a consumer-grade sleep tracker, the Oura ring. In addition to an ordinary univariate analysis of the results, we conducted multivariate testing of the Oura data using linear discriminant analysis (LDA). S2-targeted rTMS decreased sleep restlessness that significantly differed between the rTMS and sham stimulation patient groups (p=.028). In the multivariate analysis of the Oura data, LDA classification accuracy to separate the rTMS and sham groups exceeded 95% confidence level in four out of the seven tested models. In the subjective evaluation of sleep, the effect of rTMS and sham did not differ. S2-targeted rTMS influenced sleep in patients with CRPS. Improved sleep may enhance CRPS symptom alleviation and be of clinical importance. A univariate analysis could separate the rTMS and sham treatments. The multivariate analysis revealed that including multiple sleep-related parameters can be beneficial when analyzing rTMS effects on sleep. As sleep is related both to pain and quality of life, and sleep rTMS can be directly affected by rTMS, objective monitoring of sleep in various future rTMS trials could be fruitful.