Skip to content

Commit

Permalink
Add conversions to analytics meta box in popup editor
Browse files Browse the repository at this point in the history
Issue #775
  • Loading branch information
fpcorso committed Oct 8, 2020
1 parent 37e7c19 commit 64fa6fd
Showing 1 changed file with 25 additions and 28 deletions.
53 changes: 25 additions & 28 deletions classes/Admin/Popups.php
Original file line number Diff line number Diff line change
Expand Up @@ -1066,58 +1066,55 @@ public static function fill_missing_defaults( $settings = [] ) {
public static function render_analytics_meta_box() {
global $post;

$popup = pum_get_popup( $post->ID ); ?>
$popup = pum_get_popup( $post->ID );
?>
<div id="pum-popup-analytics" class="pum-meta-box">

<?php do_action( 'pum_popup_analytics_metabox_before', $post->ID ); ?>

<?php
$opens = $popup->get_event_count( 'open', 'current' );
//$conversions = $popup->get_event_count( 'conversion', 'current' );
//$conversion_rate = $opens > 0 && $opens >= $conversions ? $conversions / $opens * 100 : false;
$opens = $popup->get_event_count( 'open' );
$conversions = $popup->get_event_count( 'conversion' );
$conversion_rate = $opens > 0 && $opens >= $conversions ? $conversions / $opens * 100 : 0;
?>

<div id="pum-popup-analytics" class="pum-popup-analytics">

<table class="form-table">
<tbody>
<tr>
<td><?php _e( 'Opens', 'popup-maker' ); ?></td>
<td><?php echo $opens; ?></td>
<td><?php esc_html_e( 'Opens', 'popup-maker' ); ?></td>
<td><?php echo esc_html( $opens ); ?></td>
</tr>
<tr>
<td><?php esc_html_e( 'Conversions', 'popup-maker' ); ?></td>
<td><?php echo esc_html( $conversions ); ?></td>
</tr>
<tr>
<td><?php esc_html_e( 'Conversion Rate', 'popup-maker' ); ?></td>
<td><?php echo esc_html( round( $conversion_rate, 2 ) ); ?>%</td>
</tr>
<?php /* if ( $conversion_rate > 0 ) : ?>
<tr>
<td><?php _e( 'Conversions', 'popup-maker' ); ?></td>
<td><?php echo $conversions; ?></td>
</tr>
<?php endif; */ ?>
<?php /* if ( $conversion_rate > 0 ) : ?>
<tr>
<td><?php _e( 'Conversion Rate', 'popup-maker' ); ?></td>
<td><?php echo round( $conversion_rate, 2 ); ?>%</td>
</tr>
<?php endif; */ ?>
<tr class="separator">
<td colspan="2">
<label> <input type="checkbox" name="popup_reset_counts" id="popup_reset_counts" value="1" />
<?php _e( 'Reset Counts', 'popup-maker' ); ?>
<?php esc_html_e( 'Reset Counts', 'popup-maker' ); ?>
</label>
<?php if ( ( $reset = $popup->get_last_count_reset() ) ) : ?><br />
<small>
<strong><?php _e( 'Last Reset', 'popup-maker' ); ?>:</strong> <?php echo date( 'm-d-Y H:i', $reset['timestamp'] ); ?>
<br /> <strong><?php _e( 'Previous Opens', 'popup-maker' ); ?>:</strong> <?php echo $reset['opens']; ?>
<strong><?php esc_html_e( 'Last Reset', 'popup-maker' ); ?>:</strong> <?php echo esc_html( date( 'm-d-Y H:i', $reset['timestamp'] ) ); ?>
<br /> <strong><?php esc_html_e( 'Previous Opens', 'popup-maker' ); ?>:</strong> <?php echo esc_html( $reset['opens'] ); ?>

<?php /* if ( $reset['conversions'] > 0 ) : ?>
<?php if ( $reset['conversions'] > 0 ) : ?>
<br />
<strong><?php _e( 'Previous Conversions', 'popup-maker' ); ?>:</strong> <?php echo $reset['conversions']; ?>
<?php endif; */ ?>
<strong><?php esc_html_e( 'Previous Conversions', 'popup-maker' ); ?>:</strong> <?php echo esc_html( $reset['conversions'] ); ?>
<?php endif; ?>

<br /> <strong><?php _e( 'Lifetime Opens', 'popup-maker' ); ?>:</strong> <?php echo $popup->get_event_count( 'open', 'total' ); ?>
<br /> <strong><?php esc_html_e( 'Lifetime Opens', 'popup-maker' ); ?>:</strong> <?php echo esc_html( $popup->get_event_count( 'open', 'total' ) ); ?>

<?php /* if ( $popup->get_event_count( 'conversion', 'total' ) > 0 ) : ?>
<?php if ( $popup->get_event_count( 'conversion', 'total' ) > 0 ) : ?>
<br />
<strong><?php _e( 'Lifetime Conversions', 'popup-maker' ); ?>:</strong> <?php echo $popup->get_event_count( 'conversion', 'total' ); ?>
<?php endif; */ ?>
<strong><?php esc_html_e( 'Lifetime Conversions', 'popup-maker' ); ?>:</strong> <?php echo esc_html( $popup->get_event_count( 'conversion', 'total' ) ); ?>
<?php endif; ?>
</small>
<?php endif; ?>
</td>
Expand Down

0 comments on commit 64fa6fd

Please sign in to comment.