Join Slack
Powered by
Hi everyone, where in my nextjs app, am i supposed...
# ask-questions
s
stocky-river-58964
02/05/2023, 7:50 AM
Hi everyone, where in my nextjs app, am i supposed to set window.GROWTHBOOK_CONFIG for the visual editor? I think the growthbook script is being called before the config is set. Thanks in advance
stocky-river-58964
02/06/2023, 11:13 AM
useEffect(() => { const script = document.createElement('script'); script.src = '
http://localhost:3100/js/prod_w1v5U4jkB0JKLtrm3Iq0Qid6IvBToU0BzS3GV5Q.js
'; script.async = true; document.body.appendChild(script); window.GROWTHBOOK_CONFIG = { anonId: '123amiraliwerweafroghwowunbeleivab0980996, track: function (experimentId, variationId) { console.log('amirali', experimentId, variationId); }, }; return () => { document.body.removeChild(script); }; }, []);
stocky-river-58964
02/06/2023, 11:13 AM
This works!
stocky-river-58964
02/06/2023, 11:14 AM
One thing: if i set userId instead of anonId, it will go and generate a random id for me. I think there might be a problem in the script.
stocky-river-58964
02/06/2023, 11:33 AM
stocky-river-58964
02/06/2023, 11:33 AM
for me at least, o.a is always 1
81
Views
Open in Slack
Previous
Next