IANAL, so this is
not legal advise!
First: I think it is ethically better, because you are not giving your user's data to a large company that builds profiles of your users for their own purposes.
Second: if you pass the data to an analytics company, you share responsibility in ensuring that that data is processed according to the GDPR. Article 83 states on imposing/determining fines:
the degree of responsibility of the controller or processor taking into account technical and organisational measures implemented by them
It is up to you (as the controller) to ensure that you use a data processor that is GDPR-compliant (Article 28):
Where processing is to be carried out on behalf of a controller, the controller shall use only processors providing sufficient guarantees to implement appropriate technical and organisational measures in such a manner that processing will meet the requirements of this Regulation and ensure the protection of the rights of the data subject.
(By the way, it seems from the same article that you also need a written contract with the data processor that specifies exactly what data is provided, for which period, etc.)
---
tl;dr: it seems much easier to fulfil the obligations of the GDPR when you do not involve third parties.