Rich-text Reply

Getting the Optimizely Snippet into Launchrock

andybarr 11-20-14

Getting the Optimizely Snippet into Launchrock

Hi y'all,


Trying to integrate Optimizely with Launchrock, but can't get access to the <head>.


Tried the async code, in the LR advanced editor, to no avail.


Can't run my exciting experiment, argh!


Thanks for any help!




LR Adv Editor:

Level 2

Joel_Balmer 11-20-14

Re: Getting the Optimizely Snippet into Launchrock

Hi Andy,

I'm not familiar with Launchrock, but it appears to be a way to setup a launch page - does this mean it's just an overlay, or it it an entirely new page that the visitor is directed to? And is this page hosted by Launchrock?

Any details you can provide about how this works might help!

It is also possible to include the Optimizely snippet in the body of a page, but we recommend installing as high as possible to avoid your page 'part loading' before Optimizely kicks in - this is known as flashing. Usually, the best place to install the snippet is as high as possible in the head, but you may find that you do not experience loading / flashing issues with your snippet high in the body.
andybarr 11-20-14

Re: Getting the Optimizely Snippet into Launchrock

Hi Joel,


Page is hosted by Launchrock, yes.


I think what I need is a way to call the script using a JS function.  I have little to no knowledge in this arena, but this Google Analytics code, for example, is working fine:


// Google Analytics
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
ga('create', 'UA-XXX-X', 'auto');


I need to be able to call the project JS w/o using <script> tags, in other words (I think!).


Hope that helps!



Level 2
JDahlinANF 11-20-14

Re: Getting the Optimizely Snippet into Launchrock

[ Edited ]

Looks like you can add the script inside the JavaScript editor in the LaunchRock tool.

Perhaps like this (replacing "123456789" with your snippet's identification number):

(function() {
    var s = document.createElement('script');
    s.type = "text/javascript";
    s.async = true;
    var d = document.getElementsByTagName('head')[0];


andybarr 11-20-14

Re: Getting the Optimizely Snippet into Launchrock

Hi Napoleon,

I tried your code, and here's what happens:

BUT! I open an Incognito window, and I DO see my variations.

i removed your snippet and went back to the &lt;script&gt; snippet in my arbitrarily-added <head> tags in the html section. This also works (meaning, I see my variations, but the Diagnostics Report still does not clear successfully).

On occasion I am seeing some flickering, but this LR page loads haphazardly, anyway (not thrilled about that), so it mostly goes unnoticed.

Not sure if I'll implement the experiment.

Question: will this Diag report not passing mean anything for my analytics reports? Other drawbacks? Anyone encountered this before? (eyeballs say it's working, Optimizely says it's not)

Level 2
Amanda 11-20-14

Re: Getting the Optimizely Snippet into Launchrock

The diagnostic report is, unfortunately, not always a complete source of truth. If the editor is unable to load your page & detect the snippet, then Optimizely load your page into the editor via a proxy. This is not a problem (you're still able to edit the page as normal), but it would trigger a false error in the diagnostic report. 


Any chance you can share your URL so we can take a look and see if optimizely is properly implemented?


If the variations are running, then this seems to be a really good sign that your snippet is actually implemented correctly. If you don't want to share, then here is how I would recommend confirming: 


  • Open up the javascript console and type optimizely.
  • If you see an object returned (like in the attached screenshot), the the snippet is implemented correctly.
  • If the snippet is not implemented correctly, you will see and error message "optimizely is not defined" 



Screen Shot 2014-11-20 at 1.23.24 PM.png



Screen Shot 2014-11-20 at 1.24.28 PM.png

andybarr 11-21-14

Re: Getting the Optimizely Snippet into Launchrock

Hi Amanda,


I think we're going to abandon a/b testing on this market validation effort, due to flickering, unfortunately.


Once the campaign begins, and if we want to tweak, we'll run the experiment and check the console.


If the market is validated, and we built the main site, it should be much easier to implement Optimizely (no crazy DNS + subdomain hacky stuff in that case).


Thanks for everyone's help, excellent support from this community!

Level 2
Amanda 11-21-14

Re: Getting the Optimizely Snippet into Launchrock

Sounds good. There are some workarounds to flickering (check out the article here for details), but they are just that: workarounds. So that being said, I'm happy to help you if you decide to continue testing, but if you do end up just waiting until you build the main site, then you should be able to get Optimizely experiments up and running seamlessly. 


Let us know if we can provide any more details.