  The extension of Standard Model made by inclusion of additional $U(1)$ gauge
$L_\mu-L_\tau$ symmetry can explain the difference between the measured and the
predicted value of the muon magnetic moment and solve the tension in $B$ meson
decays. This model predicts the existence of a new, light $Z^\prime$ vector
boson, predominantly coupled to second and third generation leptons, whose
interaction with electrons is due to a loop mechanism involving muons and taus.
In this work, we present a rigorous evaluation of the upper limits in the
$Z^\prime$ parameter space, obtained from the analysis of the data collected by
the NA64-$e$ experiment at CERN SPS, that performed a search for light dark
matter with $2.84\times10^{11}$ electrons impinging with 100 GeV on an active
thick target. The resulting limits, despite being included in a region already
investigated by neutrino experiments,touch the muon $g-2$ preferred band for
values of the $Z^\prime$ mass of order of 1 MeV. The sensitivity projections
for the future high-statistics NA64-$e$ runs demonstrate the power of the
electrons/positron beam approach in this theoretical scenario.
