Hi all. We ran into a problem trying to connect Gr...
# give-feedback
n
Hi all. We ran into a problem trying to connect GrowthBook to our SPA site. We initialize the GrowthBook, set the user attributes, then call the isOn method. isOn always returns the correct value, but trackingCallback fires ONLY if the user lands on a page where isOn is called. If the user hits it via SPA transition isOn returns correct value, but trackingCallback is not fired, even if isOn has not been called on this feature before.
l
We recently installed GrowthBook on an Angular SPA and noticed this too... trackingCallback() is designed to only fire when the user is put into an experiment (once per unique experiment). For example, we're using the trackingCallback to log an "experiment_viewed" event in GA4/Firebase analytics like this:
trackGBExperiment(experiment, result) {
// Track experiment_viewed for GrowthBook integration
const experimentParams = {
event_category: "experiment",
experiment_id: experiment.key,
variation_id: result.variationId,
};
this.track("experiment_viewed", experimentParams);
}
We're just going through implementation now too... others might know better but it seems like this is triggered as part of GrowthBook initialization independently of the "isOn" function. For troubleshooting, I found it helped to test with a new user id in an incognito tab and use the GrowthBook devtools plugin.
127 Views