1.1.0 • Published 2 years ago
nullstack-google-analytics v1.1.0
Nullstack Google Analytics
Nullstack wrapper for Google Analytics
Install
npm install --save nullstack-google-analytics
Usage
All you have to do is import and render the Google Analytics tag with your project ID as an attribute
This component will listen for Nullstack route changes and track a PageView
import Nullstack from 'nullstack';
import GoogleAnalytics from 'nullstack-google-analytics';
class Application extends Nullstack {
render() {
return (
<main>
{/* your routes go here */}
<GoogleAnalytics id="REPLACE_WITH_YOUR_GOOGLE_ANALYTICS_ID" />
</main>
)
}
}
export default Application;
This component preconnects to https://www.googletagmanager.com and only adds the script tag once the application is hydrated to avoid blocking the first paint.
License
Nullstack Google Analytics is released under the MIT License.