@ngx-tiny/gtag
TypeScript icon, indicating that this package has built-in type declarations

10.0.0 • Public • Published

@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.

Package Sidebar

Install

npm i @ngx-tiny/gtag

Weekly Downloads

0

Version

10.0.0

License

MIT

Unpacked Size

78.7 kB

Total Files

26

Last publish

Collaborators

  • aavanzyl