Your question seems to conflict itself – you want to run A/B testing, but don’t want to mess up your SEO? The point of running A/B testing is to compare which page performs better, so naturally there will be a difference in how each page performs – hopefully your new page variation performs better (which is why you created a new page right?)
To answer the question, you can either load different components onto your homepage using get_template_part:
if($ab_test_version == 'a') {
get_template_part('template-parts/old-homepage-content');
} else {
get_template_part('template-parts/new-homepage-content');
}
Or you can change the entire template using the template_include filter:
function ab_test_homepage($template) {
// Set some sort of variable to divide users between A and B variations
$which_test="b";
if (is_front_page() && $which_test == 'b') {
$new_template = locate_template(array('new-homepage.php'));
if(!empty($new_template)) {
return $new_template;
}
}
return $template;
}
add_filter('template_include', 'ab_test_homepage', 99);
You of course want to add some sort of tracking and “goal” to measure the performance of both pages, but you can raise that in another question on the appropriate site.