Rich-text Reply

Using cloudflare for country filtering, editor now not working

tiwib 05-24-16
Accepted Solution

Using cloudflare for country filtering, editor now not working

[ Edited ]

Hi there,

We recently signed up for an optimizely plan, which did not include country filtering. So we have built our own country filtering.

Cloudflare passes HTTP_CF_IPCOUNTRY in the header which tells us the country the visitor is coming from, if that value equals 'US' then we attach the optimizely snippet:

if (country_code == 'US') {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = "//cdn.optimizely.com/js/1766281556.js";
document.getElementsByTagName('head')[0].appendChild(script);
}

 

This works great in actual tests and in the previews (if you remove http://optimizelypreview), but the editor has stopped working and just shows a blank page.

This is obviously because its not registering as a US person according to cloudflare, so the optimizely snippet never loads. Is there a way around this?

On one thread I heard the editor uses an iFrame, in which case I would expect it to work as normal if you are a US person, though it does not. 

Any ideas on a solution?




Level 2

bw 05-24-16
 

Re: Using cloudflare for country filtering, editor now not working

[ Edited ]

Hello,
I'm one of the support engineers here at Optimizely. It's true that the editor is loading your site in an editor, so there could be multiple reasons for displaying the white screen (e.g. mixed content, frame busting).

 

I see that you are following the recommended implementation of the snippet, which omits protocol and allows the snippet to load over http/https. However, if you specify http in the editor (Options > Editor Settings), most browsers will flag this as mixed content, and require you to enable insecure assets before proceeding.

 

Do you see a shield or lock icon in the address bar in the editor? If so, please click the icon and "load unsafe scripts/disable protection now". The following article details these steps further.

https://help.optimizely.com/hc/en-us/articles/204602997

bw
Optimizely
tiwib 05-25-16
 

Re: Using cloudflare for country filtering, editor now not working

 

Hi,

 

Yes I always click the shield icon when it shows, it still shows blank.

Here is our experiment by the way: https://app.optimizely.com/edit?experiment_id=5898001161

I think this is more of an advanced support ticket, I would appreciate if it could be escalated, we have used optimizely quite a bit without issue, It is definitely due to our conditional loading of the snippet based on a cloudflare country code.



 

Level 2
tiwib 05-30-16
 

Re: Using cloudflare for country filtering, editor now not working

Posting Byrce's solution here (it fixed the issue for me) in case other people have the same issue:

 

Alternatively, you can use our Editor Helper Chrome extension which among other things, will inject a placeholder snippet and disable proxy loading.

https://chrome.google.com/webstore/detail/optimizely/nicncpklpbcicjhlikgnpphpiknjjlpn

Level 2