Rich-text Reply

Optimizely does not change all the buttons of the page

TNoel 04-03-16
Accepted Solution

Optimizely does not change all the buttons of the page

Hi,

 

I put a variation of background colour on all the "me gusta/lo quiero" button but only the first are changed when I check the page: http://tuguialaser.com/cual-es-las-mejor-depiladora/

 

$("#post-440 > div:eq(7) > div:eq(0) > div:eq(3) > div:eq(0) > div:eq(0) > a:eq(0)").css({"background-color":"#258fef"});

 

I made it one by one because changing the class it is not working either

 

Thx for your help

Level 2

JasonDahlin 04-04-16
 

Re: Optimizely does not change all the buttons of the page

[ Edited ]

@TNoel - I see where experiments running and they are trying to update the back-ground color and the HTML of that element (2 different experiments), but I do not see anything on the page that matches that path, so nothing actually happens on the page.

 

This returns "empty" (and I do not see any button with the text "lo quiero" on it:

jQuery("#post-440 > div:eq(7) > div:eq(0) > div:eq(3) > div:eq(0) > div:eq(0) > a:eq(0)")

 

Where on the page is the button you are trying to modify?  Perhaps there is a better selector to use to locate each button.

--Jason Dahlin
Analytics and Testing Guru Smiley Happy
Experimentation Hero

Re: Optimizely does not change all the buttons of the page

Hi TNoel,

 

Thanks for your question. I do see the variation changes. I'm in variation n.4 and this is what I'm seeing (please note texts "LA QUIERO": 

 

Screen Shot 2016-04-04 at 15.02.47.png

 

Can you check whether you're bucketed in the right variation? See this article on how you can force yourself into another variation.

 

Best wishes,

Nils

robertchan 04-04-16
 

Re: Optimizely does not change all the buttons of the page

You should change your code using jQuery instead of the dollar sign, and you should definitely target the class - it works with jQuery, please see below:

 

//CHANGES BUTTONS YOU  SPECIFIED TO HAVE A BLACK BACKGROUND
jQuery('.btn_offer_block').css('backgroundColor','#000');

If you test this in your console with $ instead of jQuery, you'll see that $ is not a function (see image attached).

 

Screen Shot 2016-04-04 at 10.45.56 AM.png

 

If the code I provided doesn't work, then you have a timing issue and will need to scope out that line to window.

 

 

Robert Chan

Experimentation Hero
TNoel 04-06-16
 

Re: Optimizely does not change all the buttons of the page

Hi, thx a lot for you help

I will try the jQuery change. What's the timing issue?
Level 2
robertchan 04-06-16
 

Re: Optimizely does not change all the buttons of the page

@TNoel - the timing issue would exist if after using the code I provided, you still don't see the changes. This means that that code is shooting inappropriately. Therefore, you'd do something like a timeout or wait for your page to load before adding the code I provided. An example of a timeout would be as follows:

 

setTimeout(function(){

//CHANGES BUTTONS YOU  SPECIFIED TO HAVE A BLACK BACKGROUND
jQuery('.btn_offer_block').css('backgroundColor','#000');

},3000) //WAITS 3 SECONDS BEFORE APPLYING THE CODE WITHIN THE FUNCTION
Robert Chan

Experimentation Hero
TNoel 04-08-16
 

Re: Optimizely does not change all the buttons of the page

Awsome! It wasn't necessary for this one but I used the timeout for another test that was failling and it now works smoothly THX! Smiley Happy
Level 2
robertchan 04-08-16
 

Re: Optimizely does not change all the buttons of the page

Anytime and glad to be of help!
Robert Chan

Experimentation Hero
larita 09-13-16
 

Re: Optimizely does not change all the buttons of the page

Gracias! Me sirvió para crear la web depiladora laser . Gracias por la ayuda

Level 1