Loading Google Analytics after the user consents to cookie usage

35 Views Asked by At

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.

0

There are 0 best solutions below