Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only the id="0" Variant component is rendered. #122

Open
casamia918 opened this issue Jul 3, 2020 · 5 comments
Open

Only the id="0" Variant component is rendered. #122

casamia918 opened this issue Jul 3, 2020 · 5 comments

Comments

@casamia918
Copy link

casamia918 commented Jul 3, 2020

스크린샷 2020-07-03 오후 12 15 42

I've installed this library and used exactly as same as example code.

My app is rendering A/B test properly, as my Google optimize experiment setup.

But, when I insert simple test code like above image to check which variant component is rendered, it always rendering variant with id="0".

I think only the id="0" Variant component is rendered. But I can't understand why this happens.

I read the component source code, but it looks have no problem.

@casamia918 casamia918 changed the title Variant component is always render id="0" Only the id="0" Variant component is rendered. Jul 3, 2020
@hudovisk
Copy link
Owner

hudovisk commented Jul 3, 2020

Hey @casamia918,

Its been some time since I last used this library, but can you share more how you are testing the snippet of code? I remember that in order to run it locally you cannot use localhost for the domain, something related with the cookies used by google optimize. Maybe this stack overflow answer can help you: https://stackoverflow.com/a/56635677/13470154

@casamia918
Copy link
Author

casamia918 commented Jul 4, 2020

@hudovisk

I'm not using localhost in my domain name, but using ip address.

I've inserted google optimize snippet code at top of the index.html file, as same as the official optimize doc says.

My a/b test is working. But in your library code, only the Variant id="0" component is rendered.

At last, I've removed your library code and just inserted only the google optimize snippet code, but the a/b test is still working properly.

Now, my new question is, why should I use this library to apply google optimize? I'm confused.

@hudovisk
Copy link
Owner

hudovisk commented Jul 5, 2020

I'm not using localhost in my domain name, but using ip address.

I see, but I would still recommend to use a custom domain name when testing. You could modify your /etc/hosts file and map localhost or the ip address you use to a domain name like my.app.localhost (that was what worked for me). From my experience, when you test a variant from the google optimize dashboard it opens your custom domain in a new tab with a cookie that defines the variant, and according to the specs the domain name should have 2 dots (https://stackoverflow.com/a/1188145)

Now, my new question is, why should I use this library to apply google optimize? I'm confused.

You definitely don't need this library to use google optimize, I created it because I had a use case where I needed custom react components to show according the google optimize experiment and I couldn't get it without using the js api of google optimize. This library just abstract that away.

@casamia918
Copy link
Author

Oh, I see. Thanks

@benmercerdev
Copy link

I ran into this same issue when I was previewing on Google Optimize -- it would only show Variant 0

After I ran the "debug" preview page there was URL match error as I the page targeting I had specified didn't match my dev url.

Removing the page targeting rule on Google Optimize allowed me to view all the variants.

I added this back before starting the experiment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants