Package Exports
- @ngx-tiny/gtag
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@ngx-tiny/gtag) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
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/gtagDocumentation
Quick Start:
Install with npm:
npm install @ngx-tiny/gtag --saveAdd 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.htmlto 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.