Infinite Scroll Reload JS
I am currently working on the Optimizely A/B Headline Test Plugin for Wordpress and the site i'm working on is testing every headline on the site. The problem I'm running into is that the their is infinite scroll on many areas of the site and when the new post elements are added to the DOM the JS is not firing and switching the titles for those posts because the JS is run on page load. My question is, is there a way to reload the JS for all experiments in a project with one call? I was going to loop through all the expirements in the project and then pull the expirement JS for each and use it that way but that is going to be about 20 api calls every time the infinite scroll posts are loaded. Any guidance is much appreciated.
Solved! Go to Solution.
Another way of getting the list of all the experiments is doing a single API call for all the experiments in a project: http://developers.optimizely.com/rest/#list-experiments-in-project-16
Hey @belsmore ,
You are right - the snippet executes on intial page load. So, if content is added after the page has already loaded, the snippet does not re-run by default.
Are you familiar with Optimizely's manual activation setting? This allows you to force the experiment to run when you want it to. When you call "activate", the given experiment is run if the visitor meets the experiment's targeting conditions. You have the option to activate all manual experiments on the page, or just one specific experiment.