I am trying to implement a cookie consent for a website that uses Google Analytics. How can I load Analytics only after the user agrees to the use of cookies? Or, is there another approach I should be taking?
I tried dynamically loading the GA script, but I get gtag undefined afterwards.