Add WooCommerce Admin widget tracks (#31857)

* Add tracks events for dashboard setup widget load and click

* Add status widget tracks

* Use data attributes to track current and total steps

* Add newline at EOF

* Remove errant console logs
This commit is contained in:
Joshua T Flowers 2022-02-10 16:59:22 -05:00 committed by GitHub
parent 0f5a6e251b
commit f9cf24e50b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 2 deletions

View File

@ -9,7 +9,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<div class="dashboard-widget-finish-setup">
<div class="dashboard-widget-finish-setup" data-current-step="<?php echo esc_html( $step_number - 1 ); ?>" data-total-steps="<?php echo esc_html( $tasks_count ); ?>">
<span class='progress-wrapper'>
<svg class="circle-progress" width="17" height="17" version="1.1" xmlns="http://www.w3.org/2000/svg">
<circle r="6.5" cx="10" cy="10" fill="transparent" stroke-dasharray="40.859" stroke-dashoffset="0"></circle>
@ -27,3 +27,27 @@ if ( ! defined( 'ABSPATH' ) ) {
</div>
<div class="clear"></div>
</div>
<script type="text/javascript">
/*global jQuery */
(function( $ ) {
const widget = $( '.dashboard-widget-finish-setup' );
const currentStep = widget.data( 'current-step' );
const totalSteps = widget.data( 'total-steps' );
$( document ).on( 'ready', function() {
window.wcTracks.recordEvent( 'wcadmin_setup_widget_view', {
completed_tasks: currentStep,
total_tasks: totalSteps,
} );
});
$( '.dashboard-widget-finish-setup a' ).on( 'click', function() {
window.wcTracks.recordEvent( 'wcadmin_setup_widget_click', {
completed_tasks: currentStep,
total_tasks: totalSteps,
} );
});
})( jQuery );
</script>

View File

@ -19,7 +19,7 @@
box-sizing: border-box;
}
.progress-wrapper span {
.progress-wrapper > span {
position: relative;
top: -3px;
color: #757575;

View File

@ -1,5 +1,9 @@
/*global jQuery */
(function( $ ) {
$( document ).on( 'ready', function() {
window.wcTracks.recordEvent( 'wcadmin_status_widget_view' );
});
var recordEvent = function( link ) {
window.wcTracks.recordEvent( 'status_widget_click', {
link: link