You are here

function theme_analytics_google_ga_js in Analytics 7

1 theme call to theme_analytics_google_ga_js()
GoogleAnalyticsGaService::getOutput in analytics_google/src/GoogleAnalyticsGaService.php
Returns the output of the analytics service.

File

analytics_google/analytics_google.theme.inc, line 35

Code

function theme_analytics_google_ga_js(array &$variables) {
  $output = '';
  static $added = FALSE;
  if (!$added) {
    $url = analytics_url('https://ssl.google-analytics.com/ga.js');

    // Ensure that the original script loading only gets added once.
    $output .= "(function() {\n    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\n    ga.src = '" . $url . "';\n    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\n  })();\n";
    $added = TRUE;
  }
  return theme('analytics_js', array(
    'js' => $output,
  ));
}