-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(layout): enhance analytics component to track page URL and title
- Loading branch information
1 parent
694a5f4
commit 9df9cae
Showing
2 changed files
with
11 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 9 additions & 4 deletions
13
src/presentation/src/shared/layouts/components/Analytics.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,17 @@ | ||
--- | ||
type Props = { | ||
pathName: string; | ||
title: string; | ||
}; | ||
const props = Astro.props; | ||
--- | ||
|
||
<!-- Analytics --> | ||
<script defer src="https://analytics.ahmetcetinkaya.me/script.js" data-website-id="66bca9d1-0bab-43b6-b318-7d41bfd2f4c6" | ||
></script> | ||
|
||
<script> | ||
declare const umami: any; | ||
document.addEventListener("astro:after-swap", () => umami.track()); | ||
<script define:vars={{ pathName: props.pathName, title: props.title }}> | ||
document.addEventListener("astro:after-swap", () => | ||
umami.track((props) => ({ ...props, url: pathName, title: title })), | ||
); | ||
</script> |