Analytics
If you want to track your resume’s traffic, Zenith integrates with two analytics services out of the box: Umami and PostHog. Both of them are configured to work in a cookie-less way, respecting the privacy of your visitors and removing the need for cookie banners.
Umami setup
Umami provides the fastest way to setup a simple analytics for your website. It offers 10K events per month for free, which should be more than enough for a personal resume.
To setup Umami, you need to:
-
Create an account using their sign up form.
-
Go through their onboarding process and create a new site. You can provide local website address (
localhost:4321) if you don’t have a domain yet. -
From the “Add tracking code” step, copy the value of
data-website-idattribute from the script tag. If you miss this step, go toWebsite > Your project name > Editand copy value of theWebsite IDfield. -
To test the analytics locally, create
.envfile in the root of your project, and addPUBLIC_UMAMI_WEBSITE_ID=copied_website_idvariable. To add analytics to your production website, set thePUBLIC_UMAMI_WEBSITE_IDin the environment variables of your hosting provider.
PostHog setup
PostHog is a great choice if besides the basic analytics service you want to record user sessions. The service offers 1 million free events and 5 000 free session recordings per month.
To setup PostHog, you need to:
-
Create an account using their sign up form. Remember to check if it correctly detected your cloud region (US vs EU).
-
Create an organization. It will create a “Default project” automatically.
-
From the project’s page go to
Project > Generaland find theWeb snippetsection. -
From the snippet copy the project id and api host.
<script> !function(t,e) {/* function body */} posthog.init('project_id_to_copy',{api_host:'api_host_to_copy', /* ...rest of the config */})</script>- To test the analytics locally, create
.envfile in the root of your project, and addPUBLIC_POSTHOG_API_KEY=copied_project_idandPUBLIC_POSTHOG_API_HOST=copied_api_hostvariables. To add analytics to your production website, set those environment variables in your hosting provider.
Tracking events
You can use the trackEvent function to send custom events to the analytics service you configured. The function accepts two arguments: name of the event and optional object with event properties.
We already used this function to implement pdf_downloaded event that triggers when user clicks the resume download button. You can find the implementation here