function seotools_util in Drupal SEO Tools 6
Same name and namespace in other branches
- 7 seotools.module \seotools_util()
1 string reference to 'seotools_util'
- seotools_menu in ./
seotools.module - Implementation of hook_menu()
File
- ./
seotools.module, line 116
Code
function seotools_util() {
$params = array(
'metrics' => array(
'ga:visits',
),
'dimensions' => array(
'ga:date',
),
'sort_metric' => array(
'ga:date',
),
'start_date' => strtotime('-31 days'),
'end_date' => strtotime('-1 day'),
);
dsm($params);
$feed = google_analytics_api_report_data($params);
if ($feed->error) {
return FALSE;
}
$max_visits = 0;
foreach ($feed->results as $row) {
$data[] = $row['visits'];
$max_visits = max($row['visits'], $max_visits);
}
$chart = array(
'#chart_id' => 'visits_large_30d',
'#data' => $data,
'#type' => CHART_TYPE_LINE . ':nda',
'#size' => chart_size(1000, 80),
'#adjust_resolution' => TRUE,
'#data_colors' => array(
'AAAAAA',
),
'#chart_fill' => chart_fill('bg', '00000000'),
'#shape_markers' => array(
chart_shape_marker(0, 0, 'B', 0, $color = 'EEEEEE'),
),
'#line_styles' => array(
chart_line_style(2, 10, 0),
),
);
$last_day = end($feed->results);
$title = t('The most visits on a single day was @max. Yesterday there were @yesterday visits.', array(
'@max' => $max_visits,
'@yesterday' => $last_day['visits'],
));
$output = chart_render($chart, array(
'title' => $title,
'style' => 'height:' . $chart['#size']['#height'] . 'px; width:100%',
));
return $output;
return $output;
}