queen-raae / mixpod

Make a playlist of podcast episodes for your friend.
https://mixpod.app
0 stars 0 forks source link

Add Fathom Analytics #7

Closed raae closed 11 months ago

raae commented 11 months ago

usefathom

https://usefathom.com/docs/start/install

https://usefathom.com/docs/script/embed

raae commented 11 months ago

Make sure to configure the script so it only tracks visitors to mixpod.app, not localhost, deploy previews etc. I can't find it in the docs anymore, but it used to be by adding data-included-domains="mixpod.app"

<script src="https://cdn.usefathom.com/script.js" data-included-domains="mixpod.app" data-site="ABCDEFG" data-spa="auto" defer></script>

raae commented 11 months ago

The PR #11 does not pull in the env variable; it prints the env variable name as a string ie. no analytics are logged, so I am reponing this issue. CleanShot 2023-11-13 at 11 33 51 2@2x

raae commented 11 months ago

Looks like you need to use import.meta.env.PUBLIC_FATHOM_EMBED per docs https://docs.astro.build/en/guides/environment-variables/ and to get it to print the value and not the string import.meta.env.PUBLIC_FATHOM_EMBED you'll need to use JSX. Probably data-site={import.meta.env.PUBLIC_FATHOM_EMBED}.

If you like, you can do this in the frontmatter: const PUBLIC_FATHOM_EMBED = import.meta.env.PUBLIC_FATHOM_EMBED;

Then you'll can do the head: data-site={PUBLIC_FATHOM_EMBED}.