-
Notifications
You must be signed in to change notification settings - Fork 354
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #171 from CriticalMoments/analytics_instructions
Analytics instructions
- Loading branch information
Showing
2 changed files
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`. |