Skip to content

Commit

Permalink
Media Library: add track event to the Import Media button (#41626)
Browse files Browse the repository at this point in the history
  • Loading branch information
fushar authored Feb 7, 2025
1 parent 71ea4c6 commit 00c4981
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: added

Media Library: add track event to the Import Media button
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import jetpackAnalytics from '@automattic/jetpack-analytics';
import { __ } from '@wordpress/i18n';

document.addEventListener( 'DOMContentLoaded', function () {
Expand All @@ -11,6 +12,11 @@ document.addEventListener( 'DOMContentLoaded', function () {
importButton.role = 'button';
importButton.innerHTML = __( 'Import Media', 'jetpack-external-media' );
importButton.href = window.JETPACK_EXTERNAL_MEDIA_IMPORT_BUTTON?.href;
importButton.onclick = function () {
jetpackAnalytics.tracks.recordEvent( 'jetpack_external_media_import_media_button_click', {
page: 'media-library',
} );
};

const parentNode = addNewButton.parentNode;
const nextSibling = addNewButton.nextSibling;
Expand Down

0 comments on commit 00c4981

Please sign in to comment.