$data) {
if ($network == $key) {
$r = isset($data['name']) ? $data['name'] : '';
}
}
if ($r == '') {
$r = $key;
}
return $r;
}
function essb_conversion_position_name($position) {
//$r = array();
$content_positions = essb5_available_content_positions(true);
$button_positions = essb5_available_button_positions(true);
$mobile_positions = essb5_available_button_positions_mobile();
$r = '';
if ($position == 'shortcode') {
$r = __('Shortcode', 'essb');
}
else {
foreach ($content_positions as $key => $data) {
if ($key == 'content_'.$position) {
$r = $data['label'];
}
}
foreach ($button_positions as $key => $data) {
if ($key == $position) {
$r = $data['label'];
}
}
foreach ($mobile_positions as $key => $data) {
if ($key == $position) {
$r = $data['label'];
}
}
}
if ($position == 'more_popup') {
$r = __('More Button Social Networks Pop-up', 'essb');
}
if ($r == '') {
$r = $position;
}
return $r;
}
function essb_data_sorter($a, $b) {
$c1 = isset($a['clicks']) ? $a['clicks'] : 0;
$c2 = isset($b['clicks']) ? $b['clicks'] : 0;
$v1 = isset($a['views']) ? $a['views'] : 0;
$v2 = isset($b['views']) ? $b['views'] : 0;
if ($v1 != 0) {
$x = $c1 * 100 / $v1;
}
else {
$x = 0;
}
if ($v2 != 0) {
$y = $c2 * 100 / $v2;
}
else {
$y = 0;
}
if ($x == $y) {
return 0;
}
return ($x < $y) ? 1 : -1;
}
function essb_conversions_dashboard_report() {
$reset_conversion = isset($_REQUEST['reset_conversion']) ? $_REQUEST['reset_conversion'] : '';
$conversions_data = get_option('essb-conversions-lite');
if ($reset_conversion == 'true') {
$conversions_data = array();
delete_option('essb-conversions-lite');
update_option('essb-conversions-lite', $conversions_data, 'no', 'no');
//update_option('essb-conversions-lite', $conversions_data);
echo '';
}
if (!is_array($conversions_data)) {
$conversions_data = array();
}
$total_views = 0;
$total_clicks = 0;
if (isset($conversions_data['totals'])) {
if (isset($conversions_data['totals']['positions'])) {
foreach ($conversions_data['totals']['positions'] as $key => $data) {
$total_views += isset($data['views']) ? intval($data['views']) : 0;
$total_clicks += isset($data['clicks']) ? intval($data['clicks']) : 0;
}
}
}
if (intval($total_views) > 0) {
$total_percent = $total_clicks * 100 / $total_views;
}
else {
$total_percent = 0;
}
if (is_nan($total_percent)) {
$total_percent = 0;
}
?>
'', 'value' => 0);
$best_network = array('key' => '', 'value' => 0);
if (isset($conversions_data['totals']) && isset($conversions_data['totals']['positions'])) {
foreach ($conversions_data['totals']['positions'] as $key => $data) {
if ($key == '') continue;
$single_views = isset($data['views']) ? intval($data['views']) : 0;
$single_clicks = isset($data['clicks']) ? intval($data['clicks']) : 0;
$single_percent = $single_clicks * 100 / $single_views;
if ($best_position['key'] == '') {
$best_position['key'] = $key;
$best_position['value'] = $single_percent;
}
else {
if ($best_position['value'] < $single_percent) {
$best_position['key'] = $key;
$best_position['value'] = $single_percent;
}
}
}
}
if (isset($conversions_data['totals']) && isset($conversions_data['totals']['networks'])) {
foreach ($conversions_data['totals']['networks'] as $key => $data) {
if ($key == '') continue;
$single_views = isset($data['views']) ? intval($data['views']) : 0;
$single_clicks = isset($data['clicks']) ? intval($data['clicks']) : 0;
$single_percent = $single_clicks * 100 / $single_views;
if ($best_network['key'] == '') {
$best_network['key'] = $key;
$best_network['value'] = $single_percent;
}
else {
if ($best_network['value'] < $single_percent) {
$best_network['key'] = $key;
$best_network['value'] = $single_percent;
}
}
}
}
echo '
';
echo '';
echo '
';
echo '
Welcome to Conversions Lite
';
echo '
The smart way to optimize your social share buttons on site without being a social media expert.
';
echo '
';
echo '';
echo '
';
echo '
';
echo '
';
echo '
';
echo $total_views;
echo '
';
echo '
Views
';
echo '
';
echo '
';
echo '
';
echo $total_clicks;
echo '
';
echo '
Conversions
';
echo '
';
echo '
';
echo '
';
echo number_format($total_percent, 1).'%';
echo '
';
echo '
Conversion Rate
';
echo '
';
if ($best_position['key'] != '') {
echo '
Did you know that your best social sharing button display position is '. essb_conversion_position_name($best_position['key']).' with '.number_format($best_position['value'], 1).'% conversion rate.';
echo 'The best performing social network for your site is '.essb_conversion_network_name($best_network['key']).' with '.number_format($best_network['value'], 1).'% conversion rate.';
echo '
';
}
echo '
';
echo '';
echo '';
echo '
Overall Performance
';
echo '
';
echo 'Positions';
echo '
';
echo '
';
echo '
';
echo '
Views
';
echo '
Conversions
';
echo '
Conversion Rate
';
echo '
';
if (isset($conversions_data['totals']) && isset($conversions_data['totals']['positions'])) {
uasort($conversions_data['totals']['positions'], 'essb_data_sorter');
$is_first = true;
foreach ($conversions_data['totals']['positions'] as $key => $data) {
if ($key == '') continue;
$single_views = isset($data['views']) ? intval($data['views']) : 0;
$single_clicks = isset($data['clicks']) ? intval($data['clicks']) : 0;
$single_percent = $single_clicks * 100 / $single_views;
echo '
';
echo '
'.essb_conversion_position_name($key).'
';
echo '
'.$single_views.'
';
echo '
'.$single_clicks.'
';
echo '
'.number_format($single_percent, 1).'%
';
echo '
';
$is_first = false;
}
}
echo '
';
echo 'Social Networks';
echo '
';
echo '
';
echo '
';
echo '
Views
';
echo '
Conversions
';
echo '
Conversion Rate
';
echo '
';
if (isset($conversions_data['totals']) && isset($conversions_data['totals']['networks'])) {
uasort($conversions_data['totals']['networks'], 'essb_data_sorter');
$is_first = true;
foreach ($conversions_data['totals']['networks'] as $key => $data) {
if ($key == '') continue;
$single_views = isset($data['views']) ? intval($data['views']) : 0;
$single_clicks = isset($data['clicks']) ? intval($data['clicks']) : 0;
$single_percent = $single_clicks * 100 / $single_views;
echo '
';
echo '
'.essb_conversion_network_name($key).'
';
echo '
'.$single_views.'
';
echo '
'.$single_clicks.'
';
echo '
'.number_format($single_percent, 1).'%
';
echo '
';
$is_first = false;
}
}
echo '
';
echo '';
echo '
Historical Performance For The Past 7 Days
';
if (isset($conversions_data['dates'])) {
$dates = array();
foreach ($conversions_data['dates'] as $key => $data) {
$dates[] = $key;
}
$dates = array_reverse($dates);
ESSBOptionsFramework::draw_tabs_start($dates, array('element_id' => 'dates', 'active_tab' => 'dates-0', 'vertical' => 'true'));
$count = 0;
foreach ($dates as $key_date) {
$data_date = isset($conversions_data['dates'][$key_date]) ? $conversions_data['dates'][$key_date] : array();
ESSBOptionsFramework::draw_tab_start(array('element_id' => 'dates-'.$count, 'active' => ($count == 0 ? 'true' : 'false')));
echo '
';
echo 'Positions';
echo '
';
echo '
';
echo '
';
echo '
Views
';
echo '
Conversions
';
echo '
Conversion Rate
';
echo '
';
if (isset($data_date['positions'])) {
uasort($data_date['positions'], 'essb_data_sorter');
$is_first = true;
foreach ($data_date['positions'] as $key => $data) {
if ($key == '') continue;
$single_views = isset($data['views']) ? intval($data['views']) : 0;
$single_clicks = isset($data['clicks']) ? intval($data['clicks']) : 0;
$single_percent = $single_clicks * 100 / $single_views;
echo '
';
echo '
'.essb_conversion_position_name($key).'
';
echo '
'.$single_views.'
';
echo '
'.$single_clicks.'
';
echo '
'.number_format($single_percent, 1).'%
';
echo '
';
$is_first = false;
}
}
echo '
';
echo 'Social Networks';
echo '
';
echo '
';
echo '
';
echo '
Views
';
echo '
Conversions
';
echo '
Conversion Rate
';
echo '
';
if (isset($data_date['networks'])) {
uasort($data_date['networks'], 'essb_data_sorter');
$is_first = true;
foreach ($data_date['networks'] as $key => $data) {
if ($key == '') continue;
$single_views = isset($data['views']) ? intval($data['views']) : 0;
$single_clicks = isset($data['clicks']) ? intval($data['clicks']) : 0;
$single_percent = $single_clicks * 100 / $single_views;
echo '
';
echo '
'.essb_conversion_network_name($key).'
';
echo '
'.$single_views.'
';
echo '
'.$single_clicks.'
';
echo '
'.number_format($single_percent, 1).'%
';
echo '
';
$is_first = false;
}
}
ESSBOptionsFramework::draw_tab_end();
$count++;
}
ESSBOptionsFramework::draw_tabs_end();
}
echo '
';
}