Jdlrobson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/88248
Change subject: Story 1072 2/2: Add EventLogging to Keep Going drawer
......................................................................
Story 1072 2/2: Add EventLogging to Keep Going drawer
Log every time the CTA is shown and acted upon.
Logs 3 events - showing the user a cta, the user acting on a cta
and the user exiting the CTA.
Using edit count we can follow how far a user gets in the CTA and
using campaign step engagement in the CTA
Change-Id: Ic9ff4514677d2c2d0680ff8b9f6d211b405c5ecd
---
M includes/Resources.php
A javascripts/loggingSchemas/MobileWebCta.js
M javascripts/modules/keepgoing/KeepGoingDrawer.js
M javascripts/modules/keepgoing/keepgoing.js
4 files changed, 53 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend
refs/changes/48/88248/1
diff --git a/includes/Resources.php b/includes/Resources.php
index fbfe198..9032c46 100644
--- a/includes/Resources.php
+++ b/includes/Resources.php
@@ -293,6 +293,7 @@
'mobilefrontend-keepgoing-explain',
),
'scripts' => array(
+ 'javascripts/loggingSchemas/MobileWebCta.js',
'javascripts/modules/keepgoing/KeepGoingDrawer.js',
),
),
diff --git a/javascripts/loggingSchemas/MobileWebCta.js
b/javascripts/loggingSchemas/MobileWebCta.js
new file mode 100644
index 0000000..3fce68b
--- /dev/null
+++ b/javascripts/loggingSchemas/MobileWebCta.js
@@ -0,0 +1,37 @@
+( function( M, $ ) {
+
+ function log( status, campaign ) {
+ var
+ username = mw.config.get( 'wgUserName' ),
+ data = {
+ status: status,
+ campaign: campaign || M.query.campaign,
+ mobileMode: mw.config.get( 'wgMFMode' )
+ };
+
+ if ( username ) {
+ data.username = username;
+ data.userEditCount = mw.config.get( 'wgUserEditCount' );
+ }
+
+ return M.log( 'MobileWebCta', data );
+ }
+
+ // FIXME: Turn into common component shared with MobileWebClickTracking
?
+ function hijackLink( $el, status, campaign ) {
+ function linkHandler( ev ) {
+ ev.preventDefault();
+ var href = $( this ).attr( 'href' );
+ log( status, campaign ).always( function() {
+ window.location.href = href;
+ } );
+ }
+ $el.on( M.tapEvent( 'click' ), linkHandler );
+ }
+
+ M.define( 'loggingSchemas/MobileWebCta', {
+ log: log,
+ hijackLink: hijackLink
+ } );
+
+} )( mw.mobileFrontend, jQuery );
diff --git a/javascripts/modules/keepgoing/KeepGoingDrawer.js
b/javascripts/modules/keepgoing/KeepGoingDrawer.js
index 71a0526..4d4cb67 100644
--- a/javascripts/modules/keepgoing/KeepGoingDrawer.js
+++ b/javascripts/modules/keepgoing/KeepGoingDrawer.js
@@ -8,14 +8,22 @@
var Drawer = M.require( 'Drawer' ),
api = M.require( 'api' ),
+ campaign = 'mobile-keepgoing',
+ MobileWebCta = M.require( 'loggingSchemas/MobileWebCta' ),
KeepGoingDrawer = Drawer.extend( {
locked: true,
defaults: {
cancel: mw.msg(
'mobilefrontend-keepgoing-cancel' )
},
+ log: function( status ) {
+ MobileWebCta.log( status, campaign );
+ },
template: M.template.get( 'keepgoing/drawer' ),
initialize: function( options ) {
+ var self = this;
options = options || {};
+ options.step = parseInt( M.query.campaign_step,
10 ) || 0;
+ options.step += 1;
if ( options.tryAgain ) {
options.msg = mw.msg(
'mobilefrontend-keepgoing-explain' );
options.nextLabel = mw.msg(
'mobilefrontend-keepgoing-suggest-again' );
@@ -32,12 +40,16 @@
options = options || {};
api.get( { action: 'query', list: 'random',
rnnamespace: '0', rnlimit: 1 } ).done( function( resp ) {
var page = resp.query.random[0],
- url = mw.util.wikiGetlink(
page.title, { campaign: 'mobile-keepgoing', campaign_step: options.step } );
+ url = mw.util.wikiGetlink(
page.title, { campaign: campaign, campaign_step: options.step } );
options.nextUrl = url;
_super.call( self, options );
self.show();
- // TODO: Add event logging here
+ MobileWebCta.hijackLink( self.$(
'.continue' ), 'keepgoing-success', campaign );
+ } );
+ this.log( 'keepgoing-shown' );
+ self.$( '.cancel' ).on( 'click', function() {
+ this.log( 'keepgoing-exit' );
} );
}
} );
diff --git a/javascripts/modules/keepgoing/keepgoing.js
b/javascripts/modules/keepgoing/keepgoing.js
index 7f2c94b..f08317b 100644
--- a/javascripts/modules/keepgoing/keepgoing.js
+++ b/javascripts/modules/keepgoing/keepgoing.js
@@ -1,7 +1,7 @@
( function( M ) {
var step;
if ( M.query.campaign === 'mobile-keepgoing' ) {
- step = parseInt( M.query.campaign_step, 10);
+ step = M.query.campaign_step ? parseInt( M.query.campaign_step,
10 ) + 1 : 1;
mw.loader.using( 'mobile.keepgoing', function() {
var KeepGoingDrawer = M.require( 'KeepGoingDrawer' );
new KeepGoingDrawer( { tryAgain: true, step: step } );
--
To view, visit https://gerrit.wikimedia.org/r/88248
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic9ff4514677d2c2d0680ff8b9f6d211b405c5ecd
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits