JSPM

@ngx-tiny/gtag

10.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q33429F
  • License MIT

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

minzipped size last commit licence

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:

  1. Install with npm: npm install @ngx-tiny/gtag --save

  2. 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 { }
    
  3. 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.