  Let $G$ be a compactly generated locally compact group and $(\pi, \mathcal
H)$ a unitary representation of $G.$ The $1$-cocycles with coefficients in
$\pi$ which are harmonic (with respect to a suitable probability measure on
$G$) represent classes in the first reduced cohomology $\bar{H}^1(G,\pi).$ We
show that harmonic $1$-cocycles are characterized inside their reduced
cohomology class by the fact that they span a minimal closed subspace of
$\mathcal H.$ In particular, the affine isometric action given by a harmonic
cocycle $b$ is irreducible (in the sense that $\mathcal H$ contains no
non-empty, proper closed invariant affine subspace) if the linear span of
$b(G)$ is dense in $\mathcal H.$ The converse statement is true, if $\pi$
moreover has no almost invariant vectors. Our approach exploits the natural
structure of the space of harmonic $1$-cocycles with coefficients in $\pi$ as a
Hilbert module over the von Neumann algebra $\pi(G)',$ which is the commutant
of $\pi(G)$. Using operator algebras techniques, such as the von Neumann
dimension, we give a necessary and sufficient condition for a factorial
representation $\pi$ without almost invariant vectors to admit an irreducible
affine action with $\pi$ as linear part.
