Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/quavedev/analytics
Allows you to send your page views and more to Google Analytics
https://github.com/quavedev/analytics
analytics google-analytics meteor meteor-package
Last synced: 2 days ago
JSON representation
Allows you to send your page views and more to Google Analytics
- Host: GitHub
- URL: https://github.com/quavedev/analytics
- Owner: quavedev
- Created: 2020-09-07T17:55:55.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-07-14T15:29:15.000Z (over 3 years ago)
- Last Synced: 2024-11-11T22:36:53.629Z (2 months ago)
- Topics: analytics, google-analytics, meteor, meteor-package
- Language: JavaScript
- Homepage:
- Size: 3.91 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
- awesome-meteor - quave:analytics - A Meteor package that allows you to send your page views and more to Google Analytics. (Packages)
- awesome-meteor - quave:analytics - A Meteor package that allows you to send your page views and more to Google Analytics. (Analytics)
README
# quave:analytics
`quave:analytics` is a Meteor package that allows you to send your page views and more to Google Analytics
## Why
Every application needs to have some analytics data sent somewhere.
We use Google Analytics via a React Hook that can be used in every React app.
We believe we are not reinventing the wheel in this package but what we are doing is like putting together the wheels in the vehicle :).
## Installation
```sh
meteor add quave:analytics
meteor add server-render
```## Usage
You need to configure this package using your settings.
You need to set
- `googleAnalyticsTrackingId`: define which property (sub-level of account) of Google Analytics you want to assign.
```
{
"public": {
"packages": {
"quave:analytics": {
"googleAnalyticsTrackingId": "UA-39171111-11"
}
}
}
}```
Now you need to set up your server to return the tracking ID in your initial HTML. We do this using `sink` object from Meteor `server-render` package
On server you can use `addGoogleAnalyticsScript`
```javascript
import { onPageLoad } from 'meteor/server-render';import { addGoogleAnalyticsScript } from 'meteor/quave:analytics';
onPageLoad(sink => {
addGoogleAnalyticsScript(sink);
});
```On client you can add the tags using `initializeGoogleAnalytics`
```javascript
import { initializeGoogleAnalytics } from 'meteor/quave:analytics';Meteor.startup(() => {
initializeGoogleAnalytics();
});
```And send the page views using `useGoogleAnalyticsPageView` React hook
```javascript
import { useGoogleAnalyticsPageView } from 'meteor/quave:analytics';const Routes = () => {
useGoogleAnalyticsPageView();
}
```## Debugging
Add `debug: true` to package settings to see page view logs in the client.
### License
MIT