Rich-text Reply

custom javascript

psboxavramenko 08-18-15

custom javascript

Hello,

 

I have used VWO before, and trying to use Optimisely now.

In VWO i inserted custom script into variation, it looked like as following:

<script>

$(document).ready(function() {

smile_image_gallery();
smile_gallery_red_arrows();

});

</script>

 

Actually you can test these scripts in brouser, like here:

Variation 1: http://joxi.ru/5mdWbyJfJnM9r1?d=1

Variation 2: http://joxi.ru/823j7qPiwqkVmO?d=1

 

In Optimisely i have inserted abovementioned scripts just in header block, as following:

http://joxi.ru/KAx5P34iwLeWr8?d=1

Have i done it right or wrong?

 

Thaks in advance!

 

p.s.
experiment_id=3345920293

JDahlinANF 08-18-15
 

Re: custom javascript

[ Edited ]

Variation code is already set to be JavaScript.  Lose the opening <script> closing </script> tags.
All you need is the code:

 

You may or may not need to wait for "document ready"...

 

So try it like this to make sure it works:

$(document).ready(function() {
    smile_image_gallery();
    smile_gallery_red_arrows();
});

But looking at your libraries, it appears that the following should also work and may let the code run a little bit sooner:

window.smile_image_gallery();
window.smile_gallery_red_arrows();

 

Side note - I notice that you are loading Optimizely *after* two CSS files and two JS files.  If you ever decide to do experiments that alter something significant (redirecting users to a new page, changing images, etc.) having Optimizely *not* at the top of the page *will* result in increased "flashing" for the user.  If possible, consider moving the Optimizely snippet so that it is the very firts thing loaded by the page.