The COVID-19 pandemic led to widespread closure of universities. Many universities turned to e-learning to provide educational continuity, but they now face the challenge of how to reopen safely and resume in-class learning. This is difficult to achieve without methods for measuring the impact of school policies on student physical interactions. Here, we show that selectively deploying e-learning for larger classes is highly effective at decreasing campus-wide opportunities for student-to-student contact, while allowing most in-class learning to continue uninterrupted. We conducted a natural experiment at a large university that implemented a series of e-learning interventions during the COVID-19 outbreak. The numbers and locations of 24,000 students on campus were measured over a 17-week period by analysing >24 million student connections to the university Wi-Fi network. We show that daily population size can be manipulated by e-learning in a targeted manner according to class size characteristics. Student mixing showed accelerated growth with population size according to a power law distribution. Therefore, a small e-learning dependent decrease in population size resulted in a large reduction in student clustering behaviour. Our results suggest that converting a small number of classes to e-learning can decrease potential for disease transmission while minimising disruption to university operations. Universities should consider targeted e-learning a viable strategy for providing educational continuity during periods of low community disease transmission.