At Tinloof, we aim to create websites that retain users, and tracking their interactions is key to making that happen.
We’ll explain in this article the analytics possibilities with Sanity and how we make them possible in our projects.
The concepts discussed here apply to any Analytics tool like Google Analytics, Fathom, or Amplitude.
Each page has a unique URL, so you don’t need any extra Sanity set up to track their page views.
Since the websites we build are SPAs (Single Page Applications), we make sure to track the page view on page transition as well.
Here's an example of what such events look like when visiting Zego's website:
We add an optional “Tracking name” field to CTA schemas on Sanity.
We then add a global listener in the frontend to trigger click events on buttons that have the “Tracking name” field set.
This allows marketers to control 100% which buttons are tracked and the event names.
Here's a screenshot showing both the "Tracking name" field set on Sanity and the resulting event on Amplitude when a user clicks on the CTA:
Because Sanity is fully customizable and because the websites we build are modular, tracking possibilities are endless.
For example, if we have a form module, we can add Sanity fields to track the form submission and both the success and error states of the form.