How to control metatag module's tags from a page callback? I have some pages which are created by page callback functions. I'm using the metatag module. I'm on D7

I need to control the metatags output (specifically the description/og:description).

This documentation looks like it would have been useful, but is empty:
https://www.drupal.org/docs/7/modules/metatag/howto-assign-meta-tags-to-specific-non-entity-pages-d7

Thanks.
There's a hook for that. Here's my implementation.
&lt;?php

function mymodule_some_page_callback() {
  global $metatagOverrides;
  // ... generate your page ...

  $metatagOverrides = [
    'og:image' =&gt; 'https://example.org/the-image.jpg',
    'og:description' =&gt; 'Some description',
    ...
  ];

  return $thePage;
}

function mymodule_metatag_metatags_view_alter(&amp;$output, $instance, $options) {
if (!empty($metatagOverrides)) {
  foreach ($metatagOverrides as $tagname =&gt; $value) {
    if (array_key_exists($tagname, $output)) {
      $output[$tagname][&quot;#attached&quot;][&quot;drupal_add_html_head&quot;][0][0][&quot;#value&quot;] = $value;
    }
    else {
      $output[$tagname] = [
        '#attached' =&gt; [
          'drupal_add_html_head' =&gt; [
            [
              [
                '#theme' =&gt; 'metatag_property',
                '#tag' =&gt; 'meta',
                '#id' =&gt; &quot;{$tagname}_0&quot;,
                '#name' =&gt; $tagname,
                '#value' =&gt; $value,
                '#weight' =&gt; 100,
              ],
              &quot;{$tagname}_0&quot;,
            ]
          ]
        ]
      ];
    }
  }
}