Since migrating my personal website to Svelte, I have been building a custom analytics solution! I have documented my learnings and process in this article: https://javascript.plainenglish.io/build-your-own-website-analytics-solution-with-javascript-mongodb-and-netlify-functions-70152f31e138