Rich-text Reply

WalkME AB test

shansmith01 07-08-16

WalkME AB test

Hi I am trying to add some external JS to the website form walkme to test. I have read the docs but don't understand how to add the code the snippet you proved below


 * Usage
 *    This function will append an external JavaScript to the head of the document.
 *  @param {String} location - The location of the file you'd like to load.
 *  @param {Function} callback - [OPTIONAL] A function to call when the script has completed downloading.

 var loadScript = function(location, callback){
   var fileRef = document.createElement('script');

   if (callback) {
     if (fileRef.readyState) {  // IE
       fileRef.onreadystatechange = function() {
         if (fileRef.readyState == 'loaded' || fileRef.readyState == 'complete') {
           fileRef.onreadystatechange = null;
     } else {  // Non-IE
       fileRef.onload = function(){

   fileRef.setAttribute('src', location);

 loadScript('', function() {
   // CALLBACK - code that does something with the data returned by loading the script

The code I am trying to add to the <head> of  my variation is this


<script type="text/javascript">(function() {var walkme = document.createElement('script'); walkme.type = 'text/javascript'; walkme.async = true; walkme.src=''; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(walkme, s); window._walkmeConfig = {smartLoad:true}; })();</script>

Can i get some help please?

robertchan 07-08-16

Re: WalkME AB test

You can try this:


 /* _optimizely_evaluate=force */
function loadScript(content){
	var head   = document.head || document.getElementsByTagName('head')[0],
		fileRef = document.createElement('script');
		fileRef.setAttribute('type', 'text/javascript');
		fileRef.setAttribute('src', content);
		fileRef.async = true;
		window._walkmeConfig = {
	        smartLoad: true

/* _optimizely_evaluate=safe */

Place that in the variant you want the script to run on and look in console log to check that WalkMe has appended all its scripts on the fly.

Robert Chan

Experimentation Hero