Rich-text Reply

Using Optimizely with GWT

BookedIN 07-01-14
Accepted Solution

Using Optimizely with GWT

I'm testing out some experiments with a GWT application. I can set up variations in the editor but they don't show up when I preview them.

 

Wondering if it has to do with the way GWT loads its resources. It's a single-page app and GWT optimizes loading various JavaScript and CSS files so some of them are retrieved on-demand. So my theory is that Optimizely is trying to update the CSS after the initial page loads but GWT hasn't actually loaded the relevant CSS file yet because it's not needed yet.

 

-- Kyle

-- giddy up!
Level 2

Junan 07-01-14
 

Re: Using Optimizely with GWT

Hey Kyle,

Great question. If you try running the code that is in the editor directly into the browser console while on the page, do you see the changes apply? If so, then most likely you're correct in that its a timing issue.

By default, Optimizely executes right when the page is loaded and tries to make all of the changes prior to DOM ready. While the page is loading, we make changes to elements if they exist on the page and if not, we wait until the element loads before making the change (checking every 50ms). However, once the DOM is ready, we run all of the remaining variation code regardless of whether the elements are there. Its possible that the elements you're trying to change get added after Optimizely's variation code runs so nothing actually changes.

Typically, you can solve this issue by either using manual activation (https://help.optimizely.com/hc/en-us/articles/200040225) or by writing some code to wait for the element to load on the page (https://help.optimizely.com/hc/en-us/articles/200040635).

Hope this helps!

- Junan
Junan Pang
Optimizely
BookedIN 07-03-14
 

Re: Using Optimizely with GWT

Thanks Juan. The "Here's what's happening" section on the manual activation link sounds like that's exactly what's happening with us. I was concerned about having to use the API but the required code snippet looks innocuous enough.

-- giddy up!
Level 2
BookedIN 07-15-14
 

Re: Using Optimizely with GWT

I've tested this out in our app using manual activation as it is less intrusive and it works fine. But I have a question about the performance.

We need to call window.optimizely.push(["activate"]); in each page and dialog in our app where we might potentially want to run experiments in the future. So I was wondering what happens behind the scenes when you make the push call. I would assume it would at least need to go to the server to check for any running experiments and get the details of those experiments. But does it do that on every call or does it cache them so that they are available locally after the first call?

-- Kyle
-- giddy up!
Level 2
Junan 07-15-14
 

Re: Using Optimizely with GWT

@BookedIN 

Hey Kyle -

 

We actually don't need to go back to the server when this call is made. The Optimizely snippet has already loaded on the first page load and within that, it knows which experiments were set to manual activation and "on" at the time. When Optimizely runs the first time on page load, it will actually skip over evaluating any manually activated experiments until the window.optimizely.push(["activate"]); call is made. When this call is made, it will tell Optimizely to evaluate these manually activated experiments based on the information already contained within the Optimizely snippet from the first page load. 

 

FYI - On a single page load, you can call window.optimizely.push(["activate"]); as many times as you need (no additional loads of the Optimizely snippet). It will just keep re-evaluating any experiments set to manual activation and "on".

 

Thanks!
Junan

Junan Pang
Optimizely
BookedIN 07-17-14
 

Re: Using Optimizely with GWT

Excellent! That's good to know. Thanks Junan

-- giddy up!
Level 2