Redirect for added query parameters
I have a problem with a test I have written. The test checks if a query parameter is added to a URL, and if not - adds the parameter and reloads the page with the new URL. First I added the Optimizely_redirect comment, but this made the script for our banner go bananas in Firefox and IE and it worked much better after I removed the redirect comment. My first question is: what is the comment for? Only when the full URL is changed, or also when query parameters are added? Will goals be followed correctly on my two sites without the comment?
My second problem is stranger. When I removed the redirect comment, I get some kind of js problem in the Optimizely interface, which makes it impossible to change between variations. This is the experiment ID, 2113003807. I have tried to get around this by having two tabs open with the different variations, adding code in the code window on tab A and refreshing both tabs but then tab B changes to tab A and I can't click on B to get back because the bug appears. This is just too bisarre of a behaviour!
My next fix will be to only run one variation but this will make my result a lot less interesting.
Hoping for another type of fix, or to hear if somebody had similar problems when adding query parameters and reloading.
Can I ask exactly what you're trying to do with this experiment? I think just a little bit of insight on why the query parameter needs to be added in would be great.
In terms of the actual comment code that Optimizely adds there are a few things going on:
- That comment tells Optimizely to NOT execute that code in the editor (would explain your weird error between variations)
- It also tells Optimizely to execute all the code below the comment ASAP so the redirect happens quickly
- It also adds a cookie to stop a redirect from taking place if a redirect just happened in the last 5 seconds(this is to stop infinite loops)
You should be able to have that comment in there and still write whatever logic you need to for the redirect. What versions of FireFox and IE were having the issue and what exactly went wrong?
Also if you could add the code here that would be helpful just so I can see exactly what is going on.