Hello team! I encountered with a following proble...
# ask-questions
Hello team! I encountered with a following problem: the company's website loads not immediately, but during 4-5 seconds (sometimes even more). The reason of that falls not within the scope of my issue. But it seems like it leads to the fact, that _experiment_viewed_ event is pushed to the datalayer only after Window Loaded event was pushed. Therefore, user almost always just browses to the next page before Window Loaded event was pushed and there is no _experiment_viewed_ at all. It is clearly illustrated on a screenshot below Can anybody recommend please some custom window.gtag script, which can pushes _experiment_viewed_ earlier (maybe together with SDK or something like that)?
That can happen if your script is waiting for the GA4 clientID to load before tracking
if you use your own id, or our JS HTML tag, it can load faster
but SDK was connected via GTM and HTML generic tag yet, or what do you mean by "our JS HTML tag"? Sorry for silly question it's just the beginning working with GB and i'm a bit confused
Thank you in advance for your help, @fresh-football-47124 !
@fresh-football-47124 i'm so sorry for bothering, but can please specify what did you mean by our JS HTML tag? Because i have connected SDK via GTM and HTML Script tag. Is it the same i meant or it's another? If not, can you please send reference to documentation
"if you use your own id" - can you please send a reference related to that solution as well
Working on it
We’re adding it to our docs
Thank you for answer, that's great, i'll looking forward to it! I found the script you sent earlier: https://growthbookusers.slack.com/archives/C01T6Q1SVFV/p1713463906298439?thread_ts=1713460516.467749&cid=C01T6Q1SVFV Is that accidentally what you meant by "using your own id"?
ya, thats similar - I just updated the code slightly in the FAQ docs
Perfect, thank you very much! i'm going to dive into that guide immediately
@fresh-football-47124 in the middle of abovementioned guide there is a phrase "Note, this technique is already included with our HTML/no-code SDK" - and as I mentioned before, i connected SDK via HTML Script tag. So what should i do at this case if have done yet?
@fresh-football-47124 can you please help with this issue, please)
It should, you can share the implementation code?
It should be okay to remove the custom code
here is the only code i use to implement SDK:
Copy code
  var script = document.createElement('script');
  script.async = true;
  script.setAttribute('data-api-host', '<https://api-gb.susp.io>');
  script.setAttribute('data-client-key', 'sdk-xxxx');
  script.src = "<https://cdn.jsdelivr.net/npm/@growthbook/growthbook/dist/bundles/auto.min.js>";
Besides that tag i didn't do anything else, because in docs it says no more configuration needed Or i forgot to add something? @fresh-football-47124 "It should be okay to remove the custom code" - i don't undestand, can you specify it please)
@fresh-football-47124 good morning! Please, help with explanation of your advice, i really don't know what to do