File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change 66
77<!-- Setup Privacy-preserving Umami Analytics -->
88<svelte:head >
9+ <!-- Umami base script -->
910 <script
1011 async
1112 defer
1213 data-website-id =" 2d656c7d-b41a-4e19-934c-d7c9d91d784d"
1314 src =" https://analytics.server.orcfax.io/umami.js"
1415 ></script >
16+ <!-- Outbound-link helper -->
17+ <script async defer src =" /track-external.js" ></script >
1518</svelte:head >
1619
1720{@render children ()}
Original file line number Diff line number Diff line change 1+ /* Auto-tag all external links for Umami */
2+ ( ( ) => {
3+ const EVENT = "outbound-link-click" ;
4+
5+ function tagLinks ( ) {
6+ document . querySelectorAll ( "a" ) . forEach ( ( a ) => {
7+ if (
8+ a . host !== window . location . host && // external
9+ ! a . hasAttribute ( "data-umami-event" ) // not already tagged
10+ ) {
11+ a . setAttribute ( "data-umami-event" , EVENT ) ;
12+ a . setAttribute ( "data-umami-event-url" , a . href ) ;
13+ }
14+ } ) ;
15+ }
16+
17+ // First run
18+ tagLinks ( ) ;
19+
20+ // Re-run after every client-side navigation
21+ if ( window . __sveltekit ) {
22+ import ( "$app/navigation" ) . then ( ( { afterNavigate } ) => {
23+ afterNavigate ( tagLinks ) ;
24+ } ) ;
25+ }
26+ } ) ( ) ;
You can’t perform that action at this time.
0 commit comments