Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev/Core#53 Add in stats to AB tests and add in clickthrough and open… #11957

Merged
merged 1 commit into from
Apr 9, 2018

Conversation

seamuslee001
Copy link
Contributor

@seamuslee001 seamuslee001 commented Apr 7, 2018

…ed % stats to mailing reports

Overview

This adds Mailing delivery stat percentages to AB tests and also adds in new opened and clickthrough rate stats

Before

No AB testing % stats
screenshot 2018-04-09 14 20 48

After

AB Tests have % stats and rates.

screenshot 2018-04-09 14 23 05

@seamuslee001 seamuslee001 force-pushed the core_53 branch 2 times, most recently from b41f39e to 2d09205 Compare April 7, 2018 22:39
@eileenmcnaughton
Copy link
Contributor

test this please

@eileenmcnaughton
Copy link
Contributor

@seamuslee001 will trade for #11954

@seamuslee001
Copy link
Contributor Author

seamuslee001 commented Apr 8, 2018 via email

@@ -1997,12 +1997,16 @@ public static function &report($id, $skipDetails = FALSE, $isSMS = FALSE) {
$row['bounce_rate'] = (100.0 * $mailing->bounce) / $mailing->queue;
$row['unsubscribe_rate'] = (100.0 * $row['unsubscribe']) / $mailing->queue;
$row['optout_rate'] = (100.0 * $row['optout']) / $mailing->queue;
$row['opened_rate'] = ($row['opened'] / $mailing->delivered * 100.0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably add protection against a hard error if delivered === 0 (presumably a very obscure situation but worth handling I think)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeh i guess so

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also - can we stdise bracketting - I prefer but mostly just thing same is better

 $row['opened_rate'] = ($row['opened'] / $mailing->delivered) * 100;

with conditional

$row['opened_rate'] = $mailing->delivered ? (($row['opened'] / $mailing->delivered) * 100) : '';

@eileenmcnaughton
Copy link
Contributor

@seamuslee001 I agree with this change in principle - ie it adds additional useful information to the A-B stats report and the change is localised to that report & hence low risk. I don't believe it could have a negative impact if it works as intended.

Per comments I think each divided by line has a risk of being divided by 0 so worth going through those - in fact my test did hit that on the second mailing (I added the screen shots to the PR description above - but perhaps the after might get replaced again before merge).

Visually I think

Tracked Opens 1 (100%) is better than Tracked Opens 1 100%

I think I'd also prefer the link to be on the number & not the % but from a quick look at the code that looks like more hassle than it's worth to do that.

@seamuslee001
Copy link
Contributor Author

@eileenmcnaughton thanks for that I think i have now addressed all issues you alluded to in your review. I haven't quite got the () around on AB tests but there is at least now a ui difference between the number and the %

@@ -769,6 +769,9 @@ function civicrm_api3_mailing_stats($params) {
break;
}
}
$stats[$params['mailing_id']]['delivered_rate'] = round((100.0 * $stats[$params['mailing_id']]['Delivered']) / CRM_Mailing_Event_BAO_Queue::getTotalCount($params['mailing_id'], $params['job_id']), 2) . '%';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could these be subject to division by zero?

@eileenmcnaughton
Copy link
Contributor

@seamuslee001 I'm still seeing my Granny on the B side
screenshot 2018-04-09 16 11 34

…ed % stats to mailing reports

Update Test following changes in stats function

Fixes following on from review

Further divide by zero fixes
@seamuslee001
Copy link
Contributor Author

thanks @eileenmcnaughton hopefully fixed in latest commit

@eileenmcnaughton
Copy link
Contributor

Yes - there is an inconsistency in 0 vs na but that is not new in this PR. The grey power is gone!

screenshot 2018-04-09 16 25 48

@eileenmcnaughton
Copy link
Contributor

I'm happy this is ready to merge now - the things I observed have been addressed

@seamuslee001
Copy link
Contributor Author

Merging as it indicates merge-on-pass

@seamuslee001 seamuslee001 merged commit 7eeac05 into civicrm:master Apr 9, 2018
@eileenmcnaughton eileenmcnaughton deleted the core_53 branch April 9, 2018 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants