$data) { if ($network == $key) { $r = isset($data['name']) ? $data['name'] : ''; } } if ($r == '') { $r = $key; } return $r; } } if (!function_exists('essb_subscribe_conversion_position_name')) { function essb_subscribe_conversion_position_name($position) { $r = ''; if ($position == 'shortcode') { $r = __('Shortcode', 'essb'); } if ($position == 'widget') { $r = __('Widget', 'essb'); } if ($position == 'belowcontent') { $r = __('Subscribe Form Below Content', 'essb'); } if (strpos($position, 'flyout') !== false) { $position_data = explode('-', $position); $r = __('Subscribers Flyout', 'essb'); if ($position_data[1] == 'time') { $r .= ': Timed delay'; } if ($position_data[1] == 'scroll') { $r .= ': On scroll'; } if ($position_data[1] == 'exit') { $r .= ': Exit intent'; } } if (strpos($position, 'booster') !== false) { $position_data = explode('-', $position); $r = __('Subscribers Booster', 'essb'); if ($position_data[1] == 'time') { $r .= ': Timed delay'; } if ($position_data[1] == 'scroll') { $r .= ': On scroll'; } if ($position_data[1] == 'exit') { $r .= ': Exit intent'; } } if ($r == '') { $r = $position; } return $r; } } if (!function_exists('essb_data_sorter')) { 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_subscribe_conversions_dashboard_report() { $reset_conversion = isset($_REQUEST['reset_subscribe_conversion']) ? $_REQUEST['reset_subscribe_conversion'] : ''; $conversions_data = get_option('essb-subscribe-conversions-lite'); if ($reset_conversion == 'true') { $conversions_data = array(); update_option('essb-subscribe-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 ''.__('Reset Stored Conversion Data', 'essb').''; echo '
'; echo '
'; echo '
'; echo '
Welcome to Subscribe Conversions Lite
'; echo '
The smart way to optimize your subscribe forms 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_subscribe_conversion_position_name($best_position['key']).' with '.number_format($best_position['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_subscribe_conversion_position_name($key).'
'; echo '
'.$single_views.'
'; echo '
'.$single_clicks.'
'; echo '
'.number_format($single_percent, 1).'%
'; echo '
'; $is_first = false; } } 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_subscribe_conversion_position_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 '
'; } echo '
'; }