@ngx-tiny/gtag

![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

Usage no npm install needed!

<script type="module">
  import ngxTinyGtag from 'https://cdn.skypack.dev/@ngx-tiny/gtag';
</script>

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.