You are here

public static function GoogleAnalyticsEventTracking::isGaAttached in Google Analytics Event Tracking 8.2

Same name and namespace in other branches
  1. 8 src/GoogleAnalyticsEventTracking.php \Drupal\google_analytics_et\GoogleAnalyticsEventTracking::isGaAttached()

Evaluates whether Google Analytics itself has been attached to the page.

Parameters

$attachments:

Return value

bool

File

src/GoogleAnalyticsEventTracking.php, line 184

Class

GoogleAnalyticsEventTracking

Namespace

Drupal\google_analytics_et

Code

public static function isGaAttached($attachments) {
  if (!empty($attachments['#attached']['html_head'])) {
    foreach ($attachments['#attached']['html_head'] as $attachment) {
      if (!empty($attachment[1]) && $attachment[1] == 'google_analytics_tracking_script') {
        return TRUE;
      }
    }
  }
  return FALSE;
}