Reputation: 1975
I am developing a static site using gatsby.js. I need to set up a redirect test using Google Optimize. I created the redirect test at https://optimize.google.com and started it. After that, I used this code to set up the redirect tests in the site:
gtag('config', 'UA-48341628-1', {'optimize_id': 'GTM-XXXXXX'});
gtag('set', {'expId': 'xxxxxxxxxxxxxxxxxxxxxx'});
gtag('set', {'expVar':'New Signup Page'});
The purpose of the test is to redirect some people from /signup
to /sign-up
. But when I am going to /signup
nothing happens even if I am setting 0 weight to /signup
and 100% weight to /sign-up
. What am I doing wrong?
Upvotes: 0
Views: 336
Reputation: 1975
The problem existed as I've tried to use localhost
as the base URL which has not been recognized by Google Optimize. I've solved the problem by using http://test.io
as the base URL and have added it to my /etc/hosts
mapped to 127.0.0.1
.
Upvotes: 0
Reputation: 1633
Based on the Analytics field-reference, the Experiment Variation must be provided as the index of the selected variation, not by its name. So in your case:
gtag('set', {'expVar':'1'});
Upvotes: 1