Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Analytics instructions #171

Merged
merged 3 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ After the steps above, you’ll have a working version like the demo page. Howev
- Add actual SaaS functionality!
- Replace the admin dashboard with real content (`/src/routes/(admin)/account/+page.svelte`).
- Add API endpoints and database tables as needed to deliver your SaaS product.
- Analytics: optionally add analytics to your project. [guide](/analytics_docs.md)

## Community Extensions

Expand Down
21 changes: 21 additions & 0 deletions analytics_docs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Adding Analytics

Adding analytics to your SaaS Starter project is optional.

Since each analytics platform has different setup instructions, we've created a guide instead of adding it in code.

### PostHog

- Create a PostHog Account
- Install PostHog JS Library
- Run `npm install posthog-js` in your terminal. This will add PostHog dependencies to your `package.json` and `package-lock.json`.
- Set Up PostHog
- in `src/routes/+layout.svelte` add PostHog to the script section following the [Posthog Svelte Guide](https://posthog.com/docs/libraries/svelte#client-side-setup). Note: ensure you’re logged into PostHog so that the code includes your unique API key automatically.
- Test analytics
- Click around and view a few pages on your site to generate some events. You can view these events in PostHog to ensure tracking is active.

### Google Analytics

Follow the [Google Analytics Guide](https://support.google.com/analytics/answer/9304153?hl=en) to add Google Analytics to your project.

The ideal place to add Google Analytics is in `src/routes/+layout.svelte`.
Loading