@ngx-tiny/gtag
v10.0.0
Published
![minzipped size](https://img.shields.io/bundlephobia/minzip/@ngx-tiny/gtag?style=for-the-badge) ![last commit](https://img.shields.io/github/last-commit/aavanzyl/ngx-tiny?style=for-the-badge) ![licence](https://img.shields.io/npm/l/@ngx-tiny/gtag?style=f
Downloads
2
Maintainers
Readme
@ngx-tiny/gtag
Angular Google Analytics.
- Angular 10 implementation
- Works with SSR
- Page view service
- Event Service
- No Dependencies required
Installation
$ npm i @ngx-tiny/gtag
Documentation
Quick Start:
Install with npm:
npm install @ngx-tiny/gtag --save
Add NgxGtagModule to your @NgModule like example below
import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { GtagModule } from '@ngx-tiny/gtag'; import { AppComponent } from './app.component'; @NgModule({ imports: [ BrowserModule, GtagModule.forRoot( {trackingId : "<Your Tracking ID>"}) ], declarations: [AppComponent], bootstrap: [AppComponent] }) export class AppModule { }
Add the component to your
app.component.html
to load the scripts and start logging page views<ngx-gtag></ngx-gtag>
Event:
import { Component, OnInit } from '@angular/core';
import { GtagEventService } from '@ngx-tiny/gtag';
@Component({
selector: 'app-landing',
templateUrl: './landing.component.html',
styleUrls: ['./landing.component.sass']
})
export class LandingComponent implements OnInit {
constructor(
private gtagEventService: GtagEventService
) { }
ngOnInit() {
this.gtagEventService.event({
action: "landing",
options: { event_category: "landing loaded" }
});
}
}
Support
Support me by becoming a patron and buying me a beer :)
License
See the LICENSE file.