lesca-gtag
v3.0.2
Published
google analytics sample tracking
Downloads
141
Readme
Why use it?
use Google analytics in a simple way.
Live Demo
Installation
npm install lesca-gtag --saveUsage
install modules before DOM render
import Gtag from 'lesca-gtag';
// install on entry file
Gtag.install('your-gtag-id'); // get your id => https://analytics.google.com/analytics/web/add pageview
import Gtag from 'lesca-gtag';
// page view
Gtag.pv('your-page-name');add event
import Gtag from 'lesca-gtag';
<button
onClick={() => {
Gtag.event('your-page-name', 'action-name');
}}
>
send event
</button>Development
Methods
| method | description | return | | :----------------------------------------------------- | :-------------------------------------------: | -----: | | .install( id:string, debug:boolean ) | initialize gtag | void | | .inset(id:string) | push dataLayer without gtag.js(use gtm maybe) | void | | .pv( pageName:string ) | add page view | void | | .event(pageName:string, actionName:string) | add event | void | | .gtag( arguments:string ) | arguments | void |
Features
- maintain if necessary
