You are here

function theme_analytics_google_ga_actions_js in Analytics 7

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

File

analytics_google/analytics_google.theme.inc, line 53

Code

function theme_analytics_google_ga_actions_js(array &$variables) {
  $output = 'var _gaq = _gaq || [];' . "\n";
  foreach ($variables['actions'] as $action) {
    if (!is_array($action)) {
      $output .= $action . "\n";
    }
    else {
      $line = '_gaq.push([';
      foreach ($action as $parameter) {
        $line .= drupal_json_encode($parameter) . ',';
      }
      $line = rtrim($line, ',');
      $line .= ']);';
      $output .= $line . "\n";
    }
  }
  return $output;
}