A $4$-algebra is a commutative algebra $A$ over a field $k$ such that $(a^2)^2 = 0$, for all $a \in A$. We have proved recently \cite{Mil} that $4$-algebras play a prominent role in the classification of finite dimensional Bernstein algebras. Let $A$ be a $4$-algebra, $E$ a vector space and $\pi : E \to A$ a surjective linear map with $V = {\rm Ker} (\pi)$. All $4$-algebra structures on $E$ such that $\pi : E \to A$ is an algebra map are described and classified by a global cohomological object ${\mathbb G} {\mathbb H}^{2} \, (A, \, V)$. Any such $4$-algebra is isomorphic to a crossed product $V \# A$ and ${\mathbb G} {\mathbb H}^{2} \, (A, \, V)$ is a coproduct, over all $4$-algebras structures $\cdot_V$ on $V$, of all non-abelian cohomologies ${\mathbb H}^{2}_{\rm nab} \, \bigl(A, \, (V, \, \cdot_{V} )\bigl)$, which are the classifying objects for all extensions of $A$ by $V$. Several applications and examples are provided: in particular, ${\mathbb G} {\mathbb H}^{2} \, (A, \, k)$ and ${\mathbb G} {\mathbb H}^{2} \, (k, \, V)$ are explicitly computed and the Galois group ${\rm Gal} \, (V \# A/ V )$ of the extension $V \hookrightarrow V \# A$ is described.