https://www.growthbook.io/ logo
#ask-questions
Title
# ask-questions
a

alert-leather-41230

10/27/2023, 11:49 AM
Hi everyone, I have a question about to target an experiment. We want to conduct an experiment on the addtocart popup on our site. A user should only enter the experiment after the popup has been displayed and the product is added to the cart. When a product is added to the cart, the site send a datalayer event ‘addToCart’ but i don’t know how GB can ‘listen’ to this changes. Previously, we did this with Optimize by targeting the ‘event’ ‘addToCart.’ Can GB also listen to the data layer events? Good to know: we are using the implementation via GTM. Thanks!
1
r

rhythmic-agent-34208

10/27/2023, 11:49 AM
@blue-sundown-32899 has marked the issue as closed. Reopen Issue button
p

polite-afternoon-32745

10/27/2023, 12:49 PM
Hi @alert-leather-41230 I am also using GTM, coming from Google Optimize and interested in exactly the same thing, I hope you don't mind me sharing my understanding thus far which i'd like to have validated. You might find my pointer to activation metric useful. So far (and i'd love to be wrong) I don't believe that GrowthBook listens to the events of the data layer as targeting attributes. The only points of targeting appear to be user attributes which are set when growthbook is instantiated. It looks like you need to cast a wide net over where people might hit your experiment (so the page with the cart) And then configure an 'activation' metric as detailed here: https://docs.growthbook.io/app/experiments#:~:text=Activation%20Metric%20%2D%20A%20binomial%20metric,be%20independent%20of%20experiment%20assignment. The activation metric will be applied to your 'results' to ensure that the following occurred on either side of the experiment 1. user hits 'experiment viewed' 2. user hits 'activation metric' 3. user does or does not hit your goal metric It's important to note sequencing here matters activation must happen after targeting, and goal must happen after activation. When you look at statistical significance of a change you're then comparing activation with goal + ignoring the top level targeting which helps erradicate those who never end up going to the cart. But also ensures you can manipulate the cart before they get there so that you don't get flickering. This might have legs but i've not tested it. Does growthbook listen to changes of user attributes. Could you run something like this once they hit the cart + have a targetting attribute of accessed cart true causing them to flick into an experiment. I expect this would cause the flicker, but it might be a thing /shrug
Copy code
growthbook.setAttributes({
  accessedCart: true,
})
Does growthbook respond to changes of attributes I do not know? The dream for me would be that it was able to listen to the datalayer, That you could use a datalayer event in targetting (and this is what called trackingcallback) OR That an event you used in an activation metric when hit would call an activationcallback
a

alert-leather-41230

10/31/2023, 8:01 AM
@polite-afternoon-32745 Thanks! Hopefully there is some feature to lisiten to the datalayer events. Would be awesome 😉
f

future-teacher-7046

11/01/2023, 5:43 PM
Hi, just confirming that the
setAttributes
approach should work for now. Doing that will re-evaluate all of the visual editor experiments and apply any new ones that are now active. Automatically listening to dataLayer events is a good feature request and definitely something we should be able to support in the future
🙌 1
4 Views