Rich-text Reply

3rd party script wont load in editor. help!

brassones 04-07-16

3rd party script wont load in editor. help!

Hi

 

I have a Product recommendations script generated by Barilliance. it loads and inserts script into the DOM  on the page. I am trying to AB test the page with and without recommendations.

 

 

 

It will not load in the Editor. even with safe mode turned off and allow secure content enabled. I cannot see the Barilliance script loading and inserting their recommendations. So therefore I dont know how to select their content and turn it off for 50% of the traffic.

 

thoughts?

 

see http://www.seafolly.com.au/shop/swimwear/out-of-the-blue-patchwork-slide-tri-bikini-top-reversible-t...

 

and the recommendations are here (image)

 

https://drive.google.com/open?id=0B_ZHYIHBydn4cno4eUh2RzNVSTg

 

 

DavidS 04-08-16
 

Re: 3rd party script wont load in editor. help!

Hi brassones,

 

Thanks for reaching out to Optimizely Support!

I understand that you would like to A/B the presence of the recommendation block on the page. 

 

Before we go further, are you able to load the rest of the page in the Visual Editor or is it the full page that doesn't load in the Visual Editor? 

 

To achieve what you are looking to do, we can remove the element on the page in one of your variations. I took a look at your page and it seems like the #product-tabs > div:eq(0) CSS selector is the one responsible for displaying the recommendation products. So in the variation code, this line of code should remove the element from the page : 

$("#product-tabs > div:eq(0)").remove();

You can test if this work by using some of our Quality Assurance tools to test the experiment before it goes live. We have a dedicated article on this topic that may be of interest to you. You can check it out by clicking here

 

I hope that is helpful. Feel more than free to reply back with any additional questions at all.

 

Best,
David

 

Optimizely
robertchan 04-08-16
 

Re: 3rd party script wont load in editor. help!

@brassones here's one approach that might work for you. Let's say that Barilliance says that you need to inject the following script onto your page:

 

<script src="BARILLIANCESCRIPT"></script>

 

You can open up a new variant, and build the script as follows:

 

//CREATE A FUNCTION THAT BUILDS THE SCRIPT YOU NEED TO INJECT
var loadScript = function(location) {
	var fileRef = document.createElement('script');
	fileRef.setAttribute('type', 'text/javascript');
	fileRef.setAttribute('src', location);

	//INJECTS YOUR SCRIPT INTO THE BODY OF YOUR PAGE
	document.body.appendChild(fileRef);
};

loadScript('BARILLIANCESCRIPT');

You will need to replace BARILLIANCESCRIPT with whatever URL is in your script.

Robert Chan

Experimentation Hero