IANAL, but have worked on GDPR a fair bit.
Google Analytics is already GDPR compliant, as long as:
* you are not pushing any unencrypted customer data to them in the clear
* you're careful regards who has access to your Google Analytics data
You can (and most businesses will) argue that you need to know how your website is used. It's a completely standard practice that doesn't put user privacy at risk. Moreover, Google has already offered an opt-out to Google Analytics globally, and you would be covered by that. As such, you don't need them to opt-in.