Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Contact } from "@/components/sections/Contact";
import { ThemeProvider } from "@/contexts/ThemeContext";
import { MixerPanel } from "@/components/MixerPanel";
import { Analytics } from "@vercel/analytics/react";
import { track } from "@vercel/analytics";
import { SpeedInsights } from "@vercel/speed-insights/react";

const App = () => {
Expand All @@ -19,7 +20,9 @@ const App = () => {
useEffect(() => {
const getRoute = () => (location.hash.replace("#", "") || "about").toLowerCase();
const handleHashChange = () => {
setCurrentPage(getRoute());
const newPage = getRoute();
setCurrentPage(newPage);
track("Pageview", { path: window.location.pathname + window.location.hash });

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For analytics consistency, it's better to track a canonical path for each page. The current implementation might send different paths for the same page (e.g., / and /#about for the "About" page, or paths with different casing like /#About).

Using the newPage variable, which holds the normalized page name, to construct a canonical path would ensure that each page view is attributed to a consistent URL in your analytics. This prevents data fragmentation and provides a clearer picture of page performance.

Suggested change
track("Pageview", { path: window.location.pathname + window.location.hash });
track("Pageview", { path: `${window.location.pathname}#${newPage}` });

window.scrollTo({ top: 0, behavior: "auto" });
};
handleHashChange();
Expand Down