Following the
documentation for setting up GTM with Growthbook. We are trying to set a client_id for our AB testing. Our website has only anonymous users, so we don't have session / user id stored in a cookie.
At first we tried the GTM approach because it's tempting to use their client_id, because it should "play nicely" with our GA4 / BigQuery setup. However, overcoming the race condition of GTM not being instantiated (no
window.gtag
) before loading GB seems insurmountable at this point.
It seems to me like using a conditional to check that the
gtag
is available on the window means that growthbook just won't load in some or all situations, so that approach is
out. The same problem is compounded in the documentation where it's suggested that we wrap growthbook instance inside the
gtag('get', 'G-XXXXXX', 'client_id', fn()
call. We need that growthbook instance to create the Provider... right?
Lastly it's suggested that we should wait for the
window.onLoad()
or a GTM Trigger to run before instantiating. I think we will have the same problem here, and (this doesn't affect us yet but) it
will cause UI flashing.
I can't seem to figure out a good way to get this off the ground.