To compute $\frac{1}{2\pi i}\int_\mathcal{C} |1+z+z^2|^2 dz$ where $\mathcal{C}$ is the unit circle in $\mathbb{C}$ 
Let $\mathcal{C}$ denote the unit circle in $\mathbb{C}$ centred at the origin taken anticlockwise. Compute the value of the integrtal $$\frac{1}{2\pi i}\int_\mathcal{C} |1+z+z^2|^2 dz$$

I don't recon we can use the residue theorem to compute this integral because the integrand is not analytic anywhere.
I then tried substituting $z=e^{i\theta}$ and integrating it the traditional way but cant make much of the integrated $|1+e^{i\theta}+e^{2i\theta}|^2$.
Any help would be much appreciated. Thanks.
 A: HINT:
Note that on the unit circle $\bar z=1/z$.  Hence, we have on the unit circle
$$\left|z^2+z+1 \right|^2=(z^2+z+1)(\bar z^2+\bar z+1)=(z^2+z+1)\left(\frac{1}{z^2}+\frac1z+1\right)$$

Alternatively, using the parameterization proposed in the OP, we an write $dz=ie^{i\theta}\,d\theta$ and 
$$\begin{align}
\left|z^2+z+1 \right|^2&=(e^{i2\theta}+e^{i\theta}+1)(e^{-i2\theta}+e^{-i\theta}+1)\\\\&=3+e^{i2\theta}+2e^{i\theta}+e^{-i2\theta}+2e^{-i\theta}
\end{align}$$
A: We want the integral
$$\frac{1}{2\pi i}\int_C |1+z+z^2|^2dz=\frac{1}{2\pi}\int_0^{2\pi}|1+z+z^2|^2z~d\theta$$
since $z=e^{i\theta}$.
Now consider the absolute value portion,
$$
\begin{align}
|1+z+z^2|^2
&={(1+z+z^2)(1+z+z^2)^*}\\
&={(1+z+z^2)(1+z^{-1}+z^{-2})}\\
&={(1+z+z^2)(1+z^{-1}+z^{-2})\frac{z^2}{z^2}}\\
&={\left(\frac{1+z+z^2}{z} \right)^2}\\
&={\left(\frac{1}{z}+1+z \right)^2}\\
&={(1+2\cos\theta)^2}\\
\end{align}
$$
We can return to solve the integral
$$
\begin{align}\frac{1}{2\pi i}\int_C |1+z+z^2|^2dz
&=\frac{1}{2\pi}\int_0^{2\pi}(1+2\cos\theta)^2(\cos\theta+i\sin\theta)~d\theta\\
&=\frac{1}{2\pi}\int_0^{2\pi}(1+2\cos\theta)^2\cos\theta~d\theta\\
&=2
\end{align}$$
This is in agreement with our own numerical solution.
