Merge pull request #23253 from woocommerce/fix/edit-product-marketplace-suggestion-tracking
[3.6] Only track product page marketplace suggestions when visible.
This commit is contained in:
commit
7d1a023cf4
|
@ -318,6 +318,9 @@
|
|||
} );
|
||||
}
|
||||
|
||||
// track the current product data tab to avoid over-tracking suggestions
|
||||
var currentTab = false;
|
||||
|
||||
// Render suggestion data in appropriate places in UI.
|
||||
function displaySuggestions( marketplaceSuggestionsApiData ) {
|
||||
var usedSuggestionsContexts = [];
|
||||
|
@ -365,7 +368,17 @@
|
|||
$( this ).append( content );
|
||||
$( this ).addClass( 'showing-suggestion' );
|
||||
usedSuggestionsContexts.push( context );
|
||||
}
|
||||
|
||||
// track when suggestions are displayed (and not already visible)
|
||||
$( 'ul.product_data_tabs li.marketplace-suggestions_options a' ).click( function( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
if ( '#marketplace_suggestions' === currentTab ) {
|
||||
return;
|
||||
}
|
||||
|
||||
for ( var i in suggestionsToDisplay ) {
|
||||
window.wcTracks.recordEvent( 'marketplace_suggestion_displayed', {
|
||||
suggestion_slug: suggestionsToDisplay[ i ].slug,
|
||||
context: context,
|
||||
|
@ -375,6 +388,7 @@
|
|||
} );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
hidePageElementsForSuggestionState( usedSuggestionsContexts );
|
||||
tidyProductEditMetabox();
|
||||
|
@ -382,6 +396,12 @@
|
|||
|
||||
if ( marketplace_suggestions.suggestions_data ) {
|
||||
displaySuggestions( marketplace_suggestions.suggestions_data );
|
||||
|
||||
// track the current product data tab to avoid over-reporting suggestion views
|
||||
$( 'ul.product_data_tabs' ).on( 'click', 'li a', function( e ) {
|
||||
e.preventDefault();
|
||||
currentTab = $( this ).attr( 'href' );
|
||||
} );
|
||||
}
|
||||
|
||||
addManageSuggestionsTracksHandler();
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue