We consider a class of optimal control problems for measure-valued nonlinear transport equations describing traffic flow problems on networks. The objective is to minimise/maximise macroscopic quantities, such as traffic volume or average speed, controlling few agents, e.g. smart traffic lights and automated cars. The measure theoretic approach allows to study in a same setting local and non-local drivers interactions and to consider the control variables as additional measures interacting with the drivers distribution. We also propose a gradient descent adjoint-based optimisation method, obtained by deriving first-order optimality conditions for the control problem, and we provide some numerical experiments in the case of smart traffic lights for a 2–1 junction.