You are here

function _amp_analytics_pre_render in Accelerated Mobile Pages (AMP) 7

#pre_render callback to render amp_analytics with js library added to head.

Parameters

$elements: A render array for amp analytics elements.

Return value

The passed-in element with the js library necessary for the amp-analytics element added to head.

1 string reference to '_amp_analytics_pre_render'
amp_analytics_element_info in modules/amp_analytics/amp_analytics.module
Implements hook_element_info().

File

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

Code

function _amp_analytics_pre_render($element) {
  $head_js = array(
    '#tag' => 'script',
    '#type' => 'html_tag',
    '#attributes' => array(
      'src' => 'https://cdn.ampproject.org/v0/amp-analytics-0.1.js',
      'async' => NULL,
      'custom-element' => 'amp-analytics',
    ),
  );
  drupal_add_html_head($head_js, 'amp-analytics');
  return $element;
}