How do I add a variant programmatically?
You can try this: 

I found how to store manually created variants in code for custom pages (e.g. '/node/%node/test')

function MODULE_default_page_manager_pages() {
  // Copy exported page code here.

  $pages['UNIQUE_PAGE_ID_HERE'] = $page;

  return $pages;
}


Putting everthing in a file called 'MODULE.pages_default.inc' in your MODULE's main folder, and link that file with my MODULE.module via

/**
 * Implement hook_ctools_plugin_api().
 *
 * If you do this, CTools will pick up default panels pages in
 * MODULE.pages_default.inc
 */
function MODULE_ctools_plugin_api($module, $api) {
  if ($module == 'page_manager' &amp;&amp; $api == 'pages_default') {
    return array('version' =&gt; 1);
  }
}


Source: https://www.drupal.org/node/579036