It's a challenge. We have a section on cookies/experimentation here:
https://docs.growthbook.io/lib/script-tag#cookie-policy-and-gdpr
The idea is to create an ID for the user without persisting it. That way the experiment still runs. Then, if they do consent to cookies, you can then persist the cookie. The downside, of course, is that a user who doesn't consent may see different variations of the experiment.