Angular Module for Google Analytics
Easily add Google Analytics tracking to your Angular based project.
Getting started:
npm i angular-module-for-google-analytics
Then in your app.module.ts:
@NgModule({
imports: [
AnalyticsModule,
]
})
export class AppModule {}
And in your main component (usually app.component.ts):
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {
constructor(
private analytics: AnalyticsService,
) {
}
ngOnInit() {
this.analytics.init("UA-123456");
}
}