GB gives me a React SDK script that doesn't include this: gb.setAttributes({ id: user.id, ...
w
GB gives me a React SDK script that doesn't include this: gb.setAttributes({ id: user.id, company: user.company, }); }, [user]) But I see it in the documentation. I'm so confused by this. If I'm using GA4, should I retrieve the user-id? How can I do that?
f
What code are you using to set up the GrowthBook SDK?
w
import { GrowthBook } from "@growthbook/growthbook-react"; const growthbook = new GrowthBook({ apiHost: "https://cdn.growthbook.io", clientKey: "", enableDevMode: true, trackingCallback: (experiment, result) => { // Envía el evento al seguimiento de Google Analytics gtag('event', 'experiment_view', { event_category: "experiment", experiment_id: experiment.key, variation_id: result.key }); // Registra en consola que se visualizó el experimento console.log("Viewed Experiment", { experimentId: experiment.key, variationId: result.key }); } });
import { useEffect } from "react"; import { GrowthBookProvider } from "@growthbook/growthbook-react"; export default function MyApp() { useEffect(() => { // Load features asynchronously when the app renders growthbook.init({ streaming: true }); }, []); return ( <GrowthBookProvider growthbook={growthbook}> <MyComponent/> </GrowthBookProvider> ) }
@fresh-football-47124 @strong-mouse-55694 any chance you guys could take a look at this? Thank you!
f
do you know if the react is client side or server side?
you can set the ID from the clientID from GA4 - however, there can be a delay there, so you may want to make your own ID to use for assignment.
👍 1
(and store it)
w
I'll ask!
@fresh-football-47124 we are using React server side