In order to test redirecting locally, you have to do the following
- Create a redirect test in Google Optimize.
IMPORTANT! You cannot use
localhost
as the base URL as Google Optimize cannot recognize non-domain URLs). Pick a domain likehttp://test.io
and add a line127.0.0.1 test.io
to your/etc/hosts
. - Add
YOUR_EXPERIMENT_ID
to.env
file and to config. - Go to googleOptimize.factory.js and add
YOUR_EXPERIMENT_ID
fromconfig
tocreateGoogleOptimizeScript
. - Run
and test redirects at the domain you've added(yarn build sudo gatsby serve -p 80
http://test.io
).