You are here

function google_analytics_counter_details in Google Analytics Counter 7.3

Same name and namespace in other branches
  1. 7.2 google_analytics_counter.module \google_analytics_counter_details()

More information relevant to Google Analytics statistics for this site.

1 string reference to 'google_analytics_counter_details'
google_analytics_counter_menu in ./google_analytics_counter.module
Menu for this module

File

./google_analytics_counter.module, line 326
Basic functions for this module.

Code

function google_analytics_counter_details() {
  $result = '';
  $result .= t('<p><h3>More information relevant to Google Analytics statistics for this site:</h3>');
  $authenticated = FALSE;

  // It's a weak test but better than none.
  if (variable_get('google_analytics_counter_profile_id') != '') {
    $authenticated = TRUE;
  }
  else {
    $result .= t('<font color="red">No Google Analytics profile has been authenticated! Google Analytics Counter can not fetch any new data. Please ' . l(t('authenticate here'), 'admin/config/system/google_analytics_counter/authentication') . '.</font>');

    // Don't show anything else.
    return $result;
  }
  $result .= t('<p>Total number of hits registered by Google Analytics under this profile: %google_analytics_counter_totalhits. This is cumulative; counts for paths that may no longer exist on the website still have historical traces in Google Analytics.', array(
    '%google_analytics_counter_totalhits' => check_plain(number_format(variable_get('google_analytics_counter_totalhits', 0))),
  ));
  $result .= t('<p>Number of paths on this site as currently recorded by Google Analytics: %google_analytics_counter_totalpaths. This is cumulative; paths that may no longer exist on the website still have historical traces in Google Analytics.', array(
    '%google_analytics_counter_totalpaths' => check_plain(number_format(variable_get('google_analytics_counter_totalpaths', 0))),
  ));
  $dbresult = db_select('google_analytics_counter', 'gac')
    ->fields('gac')
    ->execute();
  $num_of_results = $dbresult
    ->rowCount();
  $result .= t('<br />Number of paths currently stored in local database table: %num_of_results. This table is initially built and then regularly updated during cron runs.', array(
    '%num_of_results' => number_format($num_of_results),
  ));
  $result .= t('<p>Total number of nodes on this site: %google_analytics_counter_totalnodes.', array(
    '%google_analytics_counter_totalnodes' => check_plain(number_format(variable_get('google_analytics_counter_totalnodes', 0))),
  ));
  if (variable_get('google_analytics_counter_storage', 0) == 0 && module_exists('statistics')) {

    // See also https://www.drupal.org/node/2275575
    $dbresult = db_select('node_counter', 'nc')
      ->fields('nc')
      ->execute();
  }
  else {
    $dbresult = db_select('google_analytics_counter_storage', 'gacs')
      ->fields('gacs')
      ->execute();
  }
  $num_of_results = $dbresult
    ->rowCount();
  $result .= t('<br />Number of nodes with known pageview counts on this site: %num_of_results.', array(
    '%num_of_results' => check_plain(number_format($num_of_results)),
  ));
  $apicalls = variable_get('google_analytics_counter_dayquota', array(
    0,
    0,
  ));
  $result .= t('<p>Number of requests made to Google Analytics: %apicalls1. Only calls made by this module are counted here. Other modules and apps may be making more requests. ', array(
    '%apicalls1' => check_plain(number_format($apicalls[1])),
  ));
  $remainingcalls = variable_get('google_analytics_counter_api_dayquota', 10000) - $apicalls[1];
  if ($remainingcalls < 1) {
    $remainingcalls = '?';
  }
  else {
    $remainingcalls = number_format($remainingcalls);
  }
  $result .= t('Remaining requests available in the current 24-hour period: %remainingcalls. ', array(
    '%remainingcalls' => check_plain($remainingcalls),
  ));
  if ($apicalls[0] == 0) {
    $temp = 60 * 60 * 24;
  }
  else {
    $temp = 60 * 60 * 24 - (REQUEST_TIME - $apicalls[0]);
  }
  $result .= t('The current 24-hour period ends in: %google_analytics_counter_sec2hms.', array(
    '%google_analytics_counter_sec2hms' => check_plain(google_analytics_counter_sec2hms($temp)),
  ));
  $temp = variable_get('google_analytics_counter_chunk_process_time', 0) + variable_get('google_analytics_counter_chunk_node_process_time', 0);
  if ($temp < 0) {
    $temp = 0;
  }
  $result .= t('<br/>The most recent retrieval of %google_analytics_counter_chunk_to_fetch paths from Google Analytics and node counts from its local mirror took %google_analytics_counter_sec2hms (%google_analytics_counter_chunk_process_time+%google_analytics_counter_chunk_node_process_times). ', array(
    '%google_analytics_counter_chunk_to_fetch' => check_plain(number_format(variable_get('google_analytics_counter_chunk_to_fetch', 0))),
    '%google_analytics_counter_sec2hms' => check_plain(google_analytics_counter_sec2hms($temp)),
    '%google_analytics_counter_chunk_process_time' => check_plain(variable_get('google_analytics_counter_chunk_process_time', 0)),
    '%google_analytics_counter_chunk_node_process_time' => check_plain(variable_get('google_analytics_counter_chunk_node_process_time', 0)),
  ));
  $temp = variable_get('google_analytics_counter_cron_next_execution', 60 * variable_get('google_analytics_counter_cron_interval', 30)) - REQUEST_TIME;
  if ($temp < 0) {
    $temp = 0;
  }
  $result .= t('The next one will take place in %google_analytics_counter_sec2hms.', array(
    '%google_analytics_counter_sec2hms' => check_plain(google_analytics_counter_sec2hms($temp)),
  ));
  $result .= t('<p>' . l(t('Run cron immediately'), 'admin/reports/status/run-cron', array(
    'query' => array(
      'destination' => 'admin/config/system/google_analytics_counter/dashboard',
    ),
  )) . '.');
  $result .= t('<p>[' . l(t('Reset all module settings'), 'admin/config/system/google_analytics_counter/dashboard/reset') . '. Useful in some cases, e.g. if in trouble with OAuth authentication.]');
  return $result;
}