Assume $G=\langle a,b:a^p=b^q=1,a^b=a^\lambda\rangle$ is a non-abelian group of order $pq$ ($p>q$). Suppose $G$ satisfies the following generalized identity of degree $k$,
\begin{equation}
x^{g_1}\cdots x^{g_k}=1.\quad(*)
\end{equation}
Taking modulo $G'$, one observe that $k$ is a multiple of $q$. Now, assume $g_i=a^{m_i}b^{n_i}$ for $i=1,\ldots,k$. From the above identity for $x=(b^j)^{a^i}$ ($j\neq0$), we obtain
\begin{equation}
(i+m_1)\lambda^{(k-1)j+n_1}+\cdots+(i+m_k)\lambda^{0j+n_k}\equiv0\pmod p.
\end{equation}
Hence, the following matrix equation arises by putting $j=1,\ldots,q-1$ in the above equation
\begin{equation}
\begin{bmatrix}
\lambda^{k-1}&\cdots&\lambda&1\\
\lambda^{2(k-1)}&\cdots&\lambda^2&1\\
\vdots&\ddots&\vdots&\vdots\\
\lambda^{(q-1)(k-1)}&\cdots&\lambda^{q-1}&1\\
\end{bmatrix}
\begin{bmatrix}
(i+m_1)\lambda^{n_1}\\
(i+m_2)\lambda^{n_2}\\
\vdots\\
(i+m_k)\lambda^{n_k}\\
\end{bmatrix}
\equiv0\pmod p.
\end{equation}
The null space of the left Vandermonde-like matrix is $k-q+1$. If $\#\{m_1,\ldots,m_k\}>1$, then the right column matrices generate a null-space of dimension at least two so that $k-q+1\geq2$ whence $k>q$. In case $\#\{m_1,\ldots,m_k\}=1$ we obtain
\begin{equation}
\begin{bmatrix}
\lambda^{k-1}&\cdots&\lambda&1\\
\lambda^{2(k-1)}&\cdots&\lambda^2&1\\
\vdots&\ddots&\vdots&\vdots\\
\lambda^{(q-1)(k-1)}&\cdots&\lambda^{q-1}&1\\
\end{bmatrix}
\begin{bmatrix}
\lambda^{n_1}\\
\lambda^{n_2}\\
\vdots\\
\lambda^{n_k}\\
\end{bmatrix}
\equiv0\pmod p.
\end{equation}
On the other hand, since $x=a$ satisfies the identity $(*)$, we get $\lambda^{n_1}+\cdots+\lambda^{n_k}\equiv0\pmod p$, from which together with the above matrix equation, it yields
\begin{equation}
\begin{bmatrix}
1&\cdots&1&1\\
\lambda^{k-1}&\cdots&\lambda&1\\
\vdots&\ddots&\vdots&\vdots\\
\lambda^{(q-1)(k-1)}&\cdots&\lambda^{q-1}&1\\
\end{bmatrix}
\begin{bmatrix}
\lambda^{n_1}\\
\lambda^{n_2}\\
\vdots\\
\lambda^{n_k}\\
\end{bmatrix}
\equiv0\pmod p.
\end{equation}
The left hand side matrix is a Vandermonde matrix when $k=q$. Being non-invertible, it follows that $k>q$ in this case too. Therefore, we must have $k\geq2q$.
For $q=2$ we have $k=4$ since
\begin{equation}
xx^ax^{ba}x^b=1
\end{equation}
for all $x\in G$. It is not difficult to see that for $q=3$ we have $k=9$ and
\begin{equation}
xx^bx^{b^2}x^{ba}x^{b^2a}x^ax^{b^2a^2}x^{a^2}x^{ba^2}=1
\end{equation}
for all $x\in G$. In general, if $\pi=(0\ 1\ \cdots\ q-1)$, then
\begin{equation}
(x^{b^{\pi^0(0)}a^0}\cdots x^{b^{\pi^0(q-1)}a^0})\cdots(x^{b^{\pi^{q-1}(0)}a^{q-1}}\cdots x^{b^{\pi^{q-1}(q-1)}a^{q-1}})=1
\end{equation}
for all $x\in G$ so that $k\leq q^2$. I believe $k=q^2$.