Skip to content

Commit

Permalink
add job instructions to google analytics (wasp-lang#245)
Browse files Browse the repository at this point in the history
  • Loading branch information
vincanger authored Jul 26, 2024
1 parent 1895003 commit 279786f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ job dailyStatsJob {
entities: [User, DailyStats, Logs, PageViewSource]
}
```
For more info on Wasp's recurring background jobs, check out the [Wasp Jobs docs](https://wasp-lang.dev/docs/advanced/jobs).
For a guide on how to integrate these services so that you can view your analytics via the dashboard, check out the [Stripe](/guides/stripe-integration) and [Analytics guide](/guides/analytics) of the docs.
Expand Down
16 changes: 14 additions & 2 deletions opensaas-sh/blog/src/content/docs/guides/analytics.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,21 @@ As a completely free, open-source project, we appreciate any help 🙏
## Google Analytics
After you sign up for [Google analytics](https://analytics.google.com/), go to your `Admin` panel in the bottom of the left sidebar and then create a "Property" for your app.
First off, head over to `src/analytics/stats.ts` and switch out the Plausible Provider for Google Analytics so that your [background (cron) job](https://wasp-lang.dev/docs/advanced/jobs) fetches the data from Google Analytics for your [Admin Dashboard](/general/admin-dashboard/):
Once you've completed the steps to create a new Property, some Installation Instructions will pop up. Select `install manually` where you should see a string that looks like this:
```ts ins={3} del={2} title="stats.ts"
//...
import { getDailyPageViews, getSources } from './providers/plausibleAnalyticsUtils';
import { getDailyPageViews, getSources } from './providers/googleAnalyticsUtils';

export const calculateDailyStats: DailyStatsJob<never, void> = async (_args, context) => {
//...
}
```
Next, make sure you sign up for [Google analytics](https://analytics.google.com/), then go to your `Admin` panel in the bottom of the left sidebar and then create a "Property" for your app.
Once you've created a new Property, some Installation Instructions will pop up. Select `install manually` where you should see a string that looks like this:
```sh title="<your-google-analytics-id>"
https://www.googletagmanager.com/gtag/js?id=<your-google-analytics-id>
Expand Down

0 comments on commit 279786f

Please sign in to comment.