Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
googleanalytics-angular
Advanced tools
Readme
Google Analytics for your Angular application
$ npm install --save googleanalytics-angular
The Google Analytics tracking script is not included in this module. Make sure to add it to your page.
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { GoogleAnalyticsModule, GA_TOKEN } from 'googleanalytics-angular';
import { AppComponent } from './app.component';
@NgModule({
imports: [
BrowserModule,
GoogleAnalyticsModule.forRoot()
],
declarations: [
AppComponent
],
bootstrap: [AppComponent],
providers: [
{ provide: GA_TOKEN, useValue: 'UA-TOKEN-1' }
]
})
export class AppModule { }
It's also possible to leave the configuration empty and configure the library later on through the service.
@NgModule({
imports: [
BrowserModule,
GoogleAnalyticsModule.forRoot()
],
declarations: [
AppComponent
],
bootstrap: [AppComponent]
})
export class AppModule { }
Inject the GoogleAnalyticsService
into your components or services.
import { Component, OnInit } from '@angular/core';
import { GoogleAnalyticsService } from 'googleanalytics-angular';
@Component({
templateUrl: 'app.component.html'
})
export class AppComponent implements OnInit {
constructor(
private gaService: GoogleAnalyticsService
) { }
ngOnInit() {
this.gaService.event.emit({
category: 'app',
action: 'bootstrap'
});
}
}
import { Component, OnInit } from '@angular/core';
import { GoogleAnalyticsService } from 'googleanalytics-angular';
@Component({
templateUrl: 'app.component.html'
})
export class AppComponent implements OnInit {
constructor(
private gaService: GoogleAnalyticsService
) { }
ngOnInit() {
this.gaService.configure('UA-TOKEN-1');
}
}
More information about named trackers can be found here
.
import { Component, OnInit } from '@angular/core';
import { GoogleAnalyticsService } from 'googleanalytics-angular';
@Component({
templateUrl: 'app.component.html'
})
export class AppComponent implements OnInit {
constructor(
private gaService: GoogleAnalyticsService
) { }
ngOnInit() {
var options = {
clientId: 'clientId',
cookieDomain: 'auto',
name: 'trackerName',
namedTracker: true
}
this.gaService.configure('UA-TOKEN-1', options);
}
}
Type: string
Tracking Id.
Type: Object
string
Default: auto
Any of the Create Only Fields
.
The ability to send to named tracker with option namedTracker
Type: boolean
Default: false
Emit a Google Analytics event.
Type: string
Typically the object that was interacted with (e.g. Video
)
Type: string
The type of interaction (e.g. play
)
Optional
Type: string
Useful for categorizing events (e.g. Fall Campaign
)
Optional
Type: number
A numeric value associated with the event (e.g. 42
)
Emit a Google Analytics page view.
Type: string
The path portion of a URL. This value should start with a slash (/) character.
Optional
Type: string
The title of the page (e.g. homepage)
##Original Author
Thanks to Sam Verschueren for the original implementation.
MIT © Mihai Stanescu
FAQs
Google Analytics for your Angular application
The npm package googleanalytics-angular receives a total of 126 weekly downloads. As such, googleanalytics-angular popularity was classified as not popular.
We found that googleanalytics-angular demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.