Skip to content

Commit

Permalink
Add tracking on back button
Browse files Browse the repository at this point in the history
  • Loading branch information
donnchawp committed Nov 26, 2024
1 parent 18ac54d commit 82438a3
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { __ } from '@wordpress/i18n';
import LeftArrow from '$svg/left-arrow';
import { useNavigate } from 'react-router-dom';
import { recordBoostEvent } from '$lib/utils/analytics';

type BackButtonProps = {
route?: string;
Expand All @@ -9,6 +10,10 @@ type BackButtonProps = {
const BackButton: React.FC< BackButtonProps > = ( { route = '/' } ) => {
const navigate = useNavigate();
const handleBack = () => {
recordBoostEvent( 'back_button_clicked', {
current_page: window.location.pathname + window.location.search + window.location.hash,
destination: route,
} );
navigate( route );
};

Expand Down

0 comments on commit 82438a3

Please sign in to comment.