Show that a theory is scale invariant I'm a bit new to this invariant transformations for fields so I've been having trouble manipulating them and I would appreciate any guidance. 
I saw in this wikipedia article that, for example, a $\phi^4$ theory, which has the Lagrangian:
$L=\frac{1}{2}(\partial_\mu\phi)^2+g\phi^4$
Is invariant under the transformations:
$x\rightarrow\lambda x \ \ \ \ \ t\rightarrow\lambda t \  \ \ \ \ \phi\rightarrow\lambda^{-1}\phi$
I tried verifying this by starting from the general scale transformation:
$x^\mu\rightarrow\lambda x^\mu \ \ \ \ \ \phi\rightarrow \lambda^{-a}\phi$
To indeed find that $a=1$ for this theory. Substituting into the Lagrangian I get:
$L=\frac{1}{2}(\partial_\mu(\lambda^{-a}\phi))^2+g(\lambda^{-a}\phi)^4$
$L=\frac{1}{2}\lambda^{-2a}(\partial_\mu\phi)^2+g\lambda^{-4a}\phi^4$
Since the action is invariant if we recover the original lagrangian plus a total derivative, I somehow have to separate the terms to recover this I could show that this theory is indeed invariant. However, I don't know how to proceed.
However, if I take the derivative of the transformation:
$\phi'(x')=\lambda^{-a}\phi(x) \ \rightarrow \ \partial\phi'(x')=\lambda^{-a}\partial\phi'(x')=$
But also:
$\phi'(x')=\phi'(\lambda x) \ \rightarrow \ \partial\phi'(x')=\lambda^{-1}\partial\phi'(x')$
Equating both terms gives me $a=1$. However, since this only depends on the derivative it should apply for any theory and not only $\phi^4$, so I'm guessing I'm doing something wrong.
 A: Just to close this question with the answer provided by AccidentalFourierTransform (thanks again for the help), I'll solve the example illustrated in case anyone finds it useful in the future.
So starting again from the transformations:
$x^\mu\rightarrow\lambda x^\mu \ \ \ \ \ \phi\rightarrow \lambda^{a}\phi$
For more clarity, these are expressed as:
$x'^{\mu}=\lambda x \ \ \ \ \ \phi'(x')=\lambda^{a}\phi(\lambda x)$
Using the chain rule, the derivative is:
$\partial_{\mu}\phi'(\lambda x)=\lambda\phi'(\lambda x)=\lambda^{a+1}\phi(x)$
Inserting into the action:
$S=\int \frac{1}{2}(\partial_\mu\phi'(x'))^2+g(\phi'(x'))^4)dx'$
$S=\int \frac{1}{2}\lambda^{2(a+1)}(\partial_\mu\phi(x))^2+\lambda^{4a}g(\phi(x))^4)dx'$
To transform the integration measure, we recall that for $x=\Lambda x'$, then $dx=det(\Lambda)dx'$, where in our case $\Lambda=\lambda I_4$. Therefore, $det(\Lambda)=\lambda^4$, so $dx=\lambda^{-4}dx'$ and thus:
$S=\int Ldx=\int (\frac{1}{2}\lambda^{2(a+1)-4}(\partial_\mu\phi(x))^2+\lambda^{4a-4}g(\phi(x))^4)dx$
Which is only satisfied if $a=1$, thus proving that this scale transformation leaves the action invariant.
