Unsure of how to use
See original GitHub issueGood day!
I am unsure as to how to actually use the module with Google Optimize.
We have a SSR-ed Nuxt application, with Google Tag Manager installed and properly set up. We recieve statistics and added the Google Optimize bingings to the GTM on the GTM’s side and it is working properly - segmentation occurs, cookie is set and all that.
Then, we’ve brought in your module, to actually react to the experiments on the server side. And this is where I get confused: your module sets the cookie with name exp
and format { experimentID }.{ variant index }
. GTM sets the cookie with name _gaexp
and format GAX1.2.2{ experimentID }.?????.{ variant index }
. Variant index actually differs between two cookies from time to time, and I don’t really know which one actually applies.
This is separate (I think) from #16, as the $exp
object is available.
Thank you for your assistance!
Issue Analytics
- State:
- Created 4 years ago
- Reactions:8
- Comments:16
Top GitHub Comments
I’ve gotten this working on our project, and it’s not that clear so I thought I’d share here. I’ll open a PR soon to update the README.
First, here’s the code sandbox: https://codesandbox.io/s/nuxt-google-optimize-example-43w4y
You’ll either get three pictures of Keanu, or three pictures of Swayze depending on which bucket Google Optimize decides you fall into. You can test this by opening a variety of private browser windows. You can refresh over and over (within Code Sandbox’s limits) and see that your list never changes: you’ve been properly bucketed.
The setup is in the nuxt.config.js file. The experiment file just has to match on the experiment ID. The nuxt config sets up Google Optimize alongside Google Analytics. What happens behind the scenes is that Google Optimize will bucket you (represented as
this.$exp.variantIndexes
) into one of the variants you created for your experiment. What this module does is automatically populate$activeVariants
with that variant’s data provided by your experiment file. This is demo’d in that code sandbox. You can edit the .env file if you want to try with your own setup.Major thing to note: tracking doesn’t show up in Google Analytics until about 24 hours later so you could easily be misled into thinking it’s not working when it probably is.
Setting up the google optimize side of things is a little unclear too, so here’s a pic of that:
I’m going to jump in here as well: it’s really not clear how this is supposed to be used. I also have GTM and GA properly set up (as far as I know), and I can retrieve the $exp object in my code. That said, nothing is getting reported back to Google Optimize and it’s not clear why that’s the case.
Could you publish a tiny sample app on how to use this on Codesandbox or something similar? That would go a long way toward understanding how to work with this module.