Index: trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.js |
— | — | @@ -2966,6 +2966,18 @@ |
2967 | 2967 | }; |
2968 | 2968 | |
2969 | 2969 | // }}} |
| 2970 | + // {{{ clickTrackingOn |
| 2971 | + |
| 2972 | + /** |
| 2973 | + * Returns whether click tracking is on |
| 2974 | + * |
| 2975 | + * @bool whether click tracking is on |
| 2976 | + */ |
| 2977 | + $.articleFeedbackv5.clickTrackingOn = function () { |
| 2978 | + return $.articleFeedbackv5.clickTracking; |
| 2979 | + }; |
| 2980 | + |
| 2981 | + // }}} |
2970 | 2982 | // {{{ trackClick |
2971 | 2983 | |
2972 | 2984 | /** |
— | — | @@ -3011,6 +3023,7 @@ |
3012 | 3024 | openAsModal: { args: 1, ret: false }, |
3013 | 3025 | closeAsModal: { args: 0, ret: true }, |
3014 | 3026 | toggleModal: { args: 1, ret: false }, |
| 3027 | + clickTrackingOn: { args: 0, ret: true }, |
3015 | 3028 | trackClick: { args: 1, ret: false } |
3016 | 3029 | }; |
3017 | 3030 | if ( opts in public ) { |
Index: trunk/extensions/ArticleFeedbackv5/modules/ext.articleFeedbackv5/ext.articleFeedbackv5.js |
— | — | @@ -16,6 +16,27 @@ |
17 | 17 | mw.util.$content.append( $aftDiv ); |
18 | 18 | } |
19 | 19 | |
| 20 | +/* Add basic edit tracking */ |
| 21 | +if ( $aftDiv.articleFeedbackv5( 'clickTrackingOn' ) ) { |
| 22 | + var clickTrackingSession = $.cookie( 'clicktracking-session' ); |
| 23 | + var editEventBase = $aftDiv.articleFeedbackv5( 'prefix', $aftDiv.articleFeedbackv5( 'bucketName' ) ); |
| 24 | + $( 'span.editsection a, #ca-edit a' ).each( function() { |
| 25 | + var event = editEventBase; |
| 26 | + if ( $(this).is( '#ca-edit a' ) ) { |
| 27 | + event += '-edit_tab_link'; |
| 28 | + } else { |
| 29 | + event += '-section_edit_link'; |
| 30 | + } |
| 31 | + var href = $( this ).attr( 'href' ); |
| 32 | + var editUrl = href + ( href.indexOf( '?' ) >= 0 ? '&' : '?' ) + $.param( { |
| 33 | + 'articleFeedbackv5_click_tracking': 1, |
| 34 | + 'articleFeedbackv5_ct_token': clickTrackingSession, |
| 35 | + 'articleFeedbackv5_ct_event': event |
| 36 | + } ); |
| 37 | + $(this).attr( 'href', $.trackActionURL( editUrl, event + '-click' ) ); |
| 38 | + } ); |
| 39 | +} |
| 40 | + |
20 | 41 | /* Setup for feedback links */ |
21 | 42 | |
22 | 43 | // Click event |
Index: trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.hooks.php |
— | — | @@ -307,12 +307,14 @@ |
308 | 308 | $ctaId = $request->getVal( 'articleFeedbackv5_cta_id' ); |
309 | 309 | $location = $request->getVal( 'articleFeedbackv5_location' ); |
310 | 310 | $token = $request->getVal( 'articleFeedbackv5_ct_token' ); |
| 311 | + $ctEvent = $request->getVal( 'articleFeedbackv5_ct_event' ); |
311 | 312 | |
312 | 313 | $editPage->editFormTextAfterContent .= Html::hidden( 'articleFeedbackv5_click_tracking', $tracking ); |
313 | 314 | $editPage->editFormTextAfterContent .= Html::hidden( 'articleFeedbackv5_bucket_id', $bucketId ); |
314 | 315 | $editPage->editFormTextAfterContent .= Html::hidden( 'articleFeedbackv5_cta_id', $ctaId ); |
315 | 316 | $editPage->editFormTextAfterContent .= Html::hidden( 'articleFeedbackv5_location', $location ); |
316 | 317 | $editPage->editFormTextAfterContent .= Html::hidden( 'articleFeedbackv5_ct_token', $token ); |
| 318 | + $editPage->editFormTextAfterContent .= Html::hidden( 'articleFeedbackv5_ct_event', $ctEvent ); |
317 | 319 | |
318 | 320 | return true; |
319 | 321 | } |
— | — | @@ -376,12 +378,17 @@ |
377 | 379 | $ctaId = $request->getVal( 'articleFeedbackv5_cta_id' ); |
378 | 380 | $location = $request->getVal( 'articleFeedbackv5_location' ); |
379 | 381 | $token = $request->getVal( 'articleFeedbackv5_ct_token' ); |
| 382 | + $ctEvent = $request->getVal( 'articleFeedbackv5_ct_event' ); |
380 | 383 | |
381 | | - $trackingId = 'ext.articleFeedbackv5@' . $version |
382 | | - . '-option' . $bucketId |
383 | | - . '-cta_' . ( isset( $ctas[$ctaId] ) ? $ctas[$ctaId] : 'unknown' ) |
384 | | - . '-' . $event |
385 | | - . '-' . $location; |
| 384 | + if ( $ctEvent ) { |
| 385 | + $trackingId = $ctEvent . '-' . $event; |
| 386 | + } else { |
| 387 | + $trackingId = 'ext.articleFeedbackv5@' . $version |
| 388 | + . '-option' . $bucketId |
| 389 | + . '-cta_' . ( isset( $ctas[$ctaId] ) ? $ctas[$ctaId] : 'unknown' ) |
| 390 | + . '-' . $event |
| 391 | + . '-' . $location; |
| 392 | + } |
386 | 393 | |
387 | 394 | $params = new FauxRequest( array( |
388 | 395 | 'action' => 'clicktracking', |