Yes, this construction works, proof below. Also, you seemed unhappy about the equivalence relation involving universal quantification over possible compact images. Fortunately, it is possible to describe it solely in terms of the topology on $X$.
A note on the space of ultrafilters.
Your equivalenceEquivalence relation on ultrafilters.
We definewant two ultrafilters $p,p'\in pX$ to be equivalent if they cannot be distinguished by continuous functions into compact spaces, i.e.
$$ p \sim p' \iff \lim_{x \to p}\ g(x) = \lim_{x \to p'}\ g(x) \quad\text{for all continuous } g:X\to C .$$$$ p \approx p' \iff \lim_{x \to p}\ g(x) = \lim_{x \to p'}\ g(x) \quad\text{for all continuous } g:X\to C .$$
This definition is somewhat unsatisfactory, since it doesn't refer to the topology of $X$ directly. Fortunately, we can use the following equivalence relation instead: two ultrafilters are considered equivalent if they cannot be "separated" by closed sets
$$ p \sim p' \iff (A \in p \wedge A'\in p' \Longrightarrow A\cap A' \in p \wedge A'\cap A \in p') \text{ for all closed sets } A,A'\subseteq X .$$
This relation might identify fewer ultrafilters than the old one, but we still have that $p \not\approx p'$ implies $p \not\sim p'$. After all, if two ultrafilters $p$ and $p'$ have different limits in some compact image $C$, then we can separate the points $g(p)$ and $g(p')$ by disjoint closed sets, for instance by using Uryson's lemma on the quasicompact Hausdorff space $C$. Pulling back these closed sets shows that $p \not\sim p'$.
$\beta X$ as quotient
We denote the quotient space with $\beta X := pX / \sim$. ThanksIt's easy to the universality ofsee that it has the space of ultrafilters $pX$universal property, it is clear thatafter all, every continuous map $g:X \to C$ lifts to a unique, continuous map $\tilde g : \beta X \to C$$\tilde g : pX \to C$, but since $g$ is continuous, its lifting also factors through the quotient $\beta X$. What remains to be shown
To finish the proof that $\beta X$ is the universal compactification, we have to show that $\beta X$ is compact and that the natural map $\iota : X \to \beta X$ is continuous.
The key point is that the ultrafilters $p_y$ and $q_y$ converge to the same point $y$ and thus cannot be distinguished by continuous functions from $X$ to some other space, i.e. $p_y \approx q_y$. Alternatively, all closed sets in $q_y$ must contain the point $y$ and we also have $p_y \sim q_y$.
Hence, theyboth ultrafilters are equal in the quotient $\beta X$,