You are here

public function GaIdService::getAnalyticsId in GA Push 8

Get the Google Analytics ID.

Either from google_analytics module service or from our own service.

Overrides GaIdServiceInterface::getAnalyticsId

File

src/GaIdService.php, line 44

Class

GaIdService
Class GaIdService.

Namespace

Drupal\ga_push

Code

public function getAnalyticsId() {
  $ga_push = $this->configFactory
    ->get('ga_push.settings');
  $google_analytics_id = $ga_push
    ->get('google_analytics_id');
  if (empty($google_analytics_id) && $this->moduleHandler
    ->moduleExists('google_analytics')) {
    $google_analytics_config = $this->configFactory
      ->get('google_analytics.settings');
    if ($google_analytics_config instanceof ImmutableConfig) {
      $google_analytics_id = $google_analytics_config
        ->get('account');
    }
  }
  return $google_analytics_id;
}