You are here

function amp_analytics_page_alter in Accelerated Mobile Pages (AMP) 7

Implements hook_page_alter().

File

modules/amp_analytics/amp_analytics.module, line 114
AMP Analytics submodule.

Code

function amp_analytics_page_alter(array &$page) {
  if (amp_is_amp_request()) {
    $google_analytics_id = variable_get('amp_google_analytics_id');
    if (!empty($google_analytics_id)) {
      $amp_analytics = array(
        '#type' => 'amp_analytics',
        '#analytics_attributes_array' => array(
          'type' => 'googleanalytics',
        ),
      );
      $page['page_bottom']['amp_analytics'] = $amp_analytics;
    }
  }
}