Rich-text Reply

Apply a variant's changes multiple times

Kenns 01-08-17

Apply a variant's changes multiple times

Howdie!  When my experiments activates, the changes are applied and everything looks perfect. When new elements are spawned, I want the changes to be applied again. Is there a way to achieve this?

Level 2

RyanC 01-09-17
 

Re: Apply a variant's changes multiple times

Seems like you would need to custom code your variation as it is specific to your website's dynamic environment,

Ryan
------------------------------------------------
The best solution is the simplest.

https://www.linkedin.com/in/ryan-camilleri
http://midnightknights.com
Experimentation Hero
JasonDahlin 01-09-17
 

Re: Apply a variant's changes multiple times

[ Edited ]

Echoing @ryn004's comments.

For situations like this, there are a couple tracks you can try:

1a- write up the code that locates any unmodified elements and modifies them

1b- place the code from 1a into a polling function (e..g, a setInterval function) so it runs every 50ms or so

1c- downside here is that this constant polling may impact browser performance making your site seem sluggish

/* _optimizely_evaluate=force */
window.myInterval = setInterval(function() {
    if ($("uniqueCSSPathHere").length > 0) {
        //code that modifies the element (be sure to add something that makes this code not run a second time on the element after it has been modified)
    }
}, 50);
/* _optimizely_evaluate=safe */

 

2a- write up the code that locates any unmodified elements and modifies them

2b- ask DEV to fire a trigger that lets you know when an item has been added to the DOM

2c- wrap your code from 2a into a function

2d- run the function from 2c once when the page loads and set up a listener for the trigger from 2b that runs the function again

/* _optimizely_evaluate=force */
function myCustomFunctionHere() {
	//code that modifies the element (be sure to add something that makes this code not run a second time on the element after it has been modified) 
}

myCustomFunctionHere(); //run it once to handle any elements that are already on the page
window.$(window).on('triggerNameHere',function(){
	myCustomFunctionHere(); //this runs when the trigger is called so that it can locate and modify whatever element was just added
});
/* _optimizely_evaluate=safe */
--Jason Dahlin
Analytics and Testing Guru Smiley Happy
Experimentation Hero
Kenns 01-14-17
 

Re: Apply a variant's changes multiple times

[ Edited ]

Thanks for the tips gentlemen! Much obliged.

 

Custom code solutions aside, I basically have a bunch of changes which my business guys create through the point and click editor. I want to apply those changes multiple times -- though it sounds like that is not possible? I have to change the experiments over into custom code. Smiley Sad

Level 2

Re: Apply a variant's changes multiple times

Key tips

Use redirects if your variation code exceeds 200 lines
Check Redirect with live query parameters included to keep the parameter attached in the variation
Use goal targeting to track clicks on the redirected variation
To map and test multiple URLs in a site redesign, use redirect URL mapping

SEO and CRO Specialist

Re: Apply a variant's changes multiple times

Hey Jason,

Correct me if I'm wrong but isn't

/* _optimizely_evaluate=force */ - /* _optimizely_evaluate=safe */

disabled in Optimizely X?
Performance Marketing Manager @ Blacklane
Founder @ Stereofox

RyanC 01-17-17
 

Re: Apply a variant's changes multiple times

I'm also under impression that the force feature is not available in Optimizely X, as now you have the feature to launch your code Synchronous/Asynchronous to the site.
Ryan
------------------------------------------------
The best solution is the simplest.

https://www.linkedin.com/in/ryan-camilleri
http://midnightknights.com
Experimentation Hero