Skip to content

Commit

Permalink
Add fathom event for when the year is changed
Browse files Browse the repository at this point in the history
  • Loading branch information
edvinlinden committed Dec 10, 2023
1 parent 5634338 commit 77ec28a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/components/YearNavigationBar/YearNavigationBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,21 @@ const YearNavigationBar: React.FC<YearNavigationBarInterface> = ({

let onYearChange = (event: any) => {
event.preventDefault();
location.hash = "#" + event.target.value;
const year = event.target.value;
const disableTracking = import.meta.env.DEV;

location.hash = "#" + year;

if (!disableTracking) {
window.fathom.trackEvent("Change year", {
_value: year,
});
}
};

return (
<div className={styles.container}>
<label for="year-select">Go to year</label>
<label htmlFor="year-select">Go to year</label>
<select
className={styles.select}
onChange={onYearChange}
Expand Down

0 comments on commit 77ec28a

Please sign in to comment.