  A measurement is presented for the electroweak production of a W boson, a
photon ($\gamma$), and two jets (j) in proton-proton collisions. The leptonic
decay of the W boson is selected by requiring one identified electron or muon
and large missing transverse momentum. The two jets are required to have large
invariant dijet mass and large separation in pseudorapidity. The measurement is
performed with the data collected by the CMS detector at a center-of-mass
energy of 13 TeV, corresponding to an integrated luminosity of 138 fb$^{-1}$.
The cross section for the electroweak W$\gamma$jj production is 23.5
$^{+4.9}_{-4.7}$ fb, whereas the total cross section for W$\gamma$jj production
is 113 $\pm$ 13 fb. Differential cross sections are also measured with the
distributions unfolded to the particle level. All results are in agreement with
the standard model expectations. Constraints are placed on anomalous quartic
gauge couplings (aQGCs) in terms of dimension-8 effective field theory
operators. These are the most stringent limits to date on the aQGCs parameters
$f_\mathrm{M,2-5}$ $/$ $\Lambda^4$ and $f_\mathrm{T,6-7}$ $/$ $\Lambda^4$.
