You are here

public function GTMContainer::noscriptTag in GoogleTagManager 7.2

Returns tag array for the snippet type.

Parameters

string $type: (optional) The snippet type.

int $weight: (optional) The weight of the item.

Return value

array The tag array.

File

includes/entity/container.inc, line 607

Class

GTMContainer
Defines the container configuration entity.

Code

public function noscriptTag($type = 'noscript', $weight = -10) {

  // Note: depending on the theme, this may not place the snippet immediately
  // after the body tag but should be close and it can be altered.
  // https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-hidden_attribute
  // Do not add aria-hidden if element or ancestor is hidden with
  // display:none or visibility:hidden. Both are on the iframe tag inside the
  // noscript tag.
  // TRUE outputs as aria-hidden="1"
  $uri = $this
    ->snippetURI($type);
  $url = drupal_realpath($uri);
  $contents = @file_get_contents($url);
  $attachment = $contents ? array(
    "google_tag_{$type}_tag__{$this->id()}" => array(
      '#type' => 'html_tag',
      '#tag' => 'noscript',
      '#value' => $contents,
      '#attributes' => array(
        'aria-hidden' => 'true',
      ),
    ),
  ) : array();
  return $attachment;
}