Support Log in

4. A/B Testing Meta Fields

Developer Guide
Prefer video? Watch the Rank Forge tutorials 9 short guides covering every feature Watch

Time-based meta title/description rotation fields. PRO feature.

Meta KeyTypeDescription
_rankforge_ab_enabledboolWhether an A/B test is currently active on this post.
_rankforge_ab_title_bstringVariant B title text. Variant A is the regular _rankforge_meta_title or template.
_rankforge_ab_desc_bstringVariant B meta description text.
_rankforge_ab_startint (timestamp)Unix timestamp when the test started. Used to calculate weekly variant rotation.
_rankforge_ab_currentstring ('a' or 'b')The currently active variant (recalculated on each page load).
_rankforge_ab_served_aintApproximate number of page views on your site (page loads, bots left out) counted for variant A. These are not Google’s impressions.
_rankforge_ab_served_bintApproximate number of page views on your site (page loads, bots left out) counted for variant B. These are not Google’s impressions.
_rankforge_ab_endint (timestamp)Unix timestamp of the moment the test was switched off. The Search Console comparison of the finished test stops there. Removed when a new test starts.
_rankforge_ab_gscarrayWhat Google Search Console last reported for the page (clicks, impressions and average position by day), with the test, property and address it was asked for. While the test runs it is reused for up to a day and then asked for again; once a finished test has settled it is not asked for again and stays as it is. Removed when a new test starts.
php
// ----- Starting an A/B test programmatically -----

$post_id = 42;

update_post_meta( $post_id, '_rankforge_ab_enabled', true );
update_post_meta( $post_id, '_rankforge_ab_title_b', 'Alternative SEO Title for A/B Testing' );
update_post_meta( $post_id, '_rankforge_ab_desc_b', 'This is the alternative description being tested.' );
update_post_meta( $post_id, '_rankforge_ab_start', time() );
update_post_meta( $post_id, '_rankforge_ab_served_a', 0 );
update_post_meta( $post_id, '_rankforge_ab_served_b', 0 );
php
// ----- Reading A/B test status -----

$post_id = 42;

$enabled = get_post_meta( $post_id, '_rankforge_ab_enabled', true );
$variant = get_post_meta( $post_id, '_rankforge_ab_current', true );
$start   = (int) get_post_meta( $post_id, '_rankforge_ab_start', true );
$weeks   = floor( ( time() - $start ) / WEEK_IN_SECONDS );

$served_a = (int) get_post_meta( $post_id, '_rankforge_ab_served_a', true );
$served_b = (int) get_post_meta( $post_id, '_rankforge_ab_served_b', true );

// Calculate which variant should be active right now
$calculated_variant = ( $weeks % 2 === 0 ) ? 'a' : 'b';

// Stop A/B test and keep the winner
update_post_meta( $post_id, '_rankforge_ab_enabled', false );

—

Forge AI Assistant Online

Hi! I'm the Rank Forge AI assistant. Ask me anything about the plugin — setup, features, troubleshooting, or development.

Just now
Powered by Forge AI · Browse docs