Rich-text Reply

state.getRedirectInfo() not available

sandeep89 06-06-18

state.getRedirectInfo() not available

Hey,

 

I'm trying to find the redirect info on the page I've been redirected to, but the call is returning null.

 

The test is a simple one - redirecting from a homepage to a single URL, using the URL text field (not code). It's currently in Draft mode - not sure if that makes a difference.

 

Can anyone help me understand why?

 

Thanks,

Sandeep.

JasonDahlin 06-06-18
 

Re: state.getRedirectInfo() not available

[ Edited ]

state.getRedirectInfo, by itself, is not valid.
Can you share all of the relevant code?  Hopefully it looks something like the following (if you were trying to access the referring URL)

 

var state = window.optimizely.get('state');
var redirectInfo = state.getRedirectInfo();
if (redirectInfo !== null) {
    console.log('redirectInfo.experimentId:'+redirectInfo.experimentId);
    console.log('redirectInfo.variationId:'+redirectInfo.variationId);
    console.log('redirectInfo.referrer:'+redirectInfo.referrer);
} else {
    console.log('redirectInfo is null - are you sure Optimizely redirected you to this page');
}
--Jason Dahlin
Analytics and Testing Guru Smiley Happy


Experimentation Hero
sandeep89 06-11-18
 

Re: state.getRedirectInfo() not available

I've got a redirect test, that's happening via. Optimizely X Web for sure.

The code I'm running is the first line, followed by the two lines it outputs:
optimizely.get('state').getRedirectInfo()
> 34737| Optly / API / Getting module: "state"
> null

I believe this is only happening in Preview mode - have live redirect tests which don't seem to be suffering from the same null responses.

get('state') seems to work though:
optimizely.get('state')
> 148992| Optly / API / Getting module: "state"
{getCampaignStates: ƒ, getExperimentStates: ƒ, getCampaignStateLists: ƒ, getPageStates: ƒ, isGlobalHoldback: ƒ, …}

Any ideas why it's not available specifically in Preview mode?
I'm trying to fix some GA tracking issues, and really need this info.