@hakimio/ngx-google-analytics
Version:
A simple Google Analytics wrapper for Angular apps
92 lines (91 loc) • 3.04 kB
TypeScript
import { GaActionEnum } from '../enums/ga-action.enum';
import { IGoogleAnalyticsServiceAppView, IGoogleAnalyticsServiceEvent, IGoogleAnalyticsServicePageView } from '../interfaces/i-google-analytics-sevice';
import { Primitive } from '../types/primitive.type';
import { GtagFn } from '../types/gtag.type';
import * as i0 from "@angular/core";
export declare class GoogleAnalyticsService {
private readonly settings;
private readonly _document;
private readonly _gtag;
private get document();
/**
* Call native GA Tag
*/
gtag: GtagFn;
/**
* Send an event trigger to GA. This is the same as:
* ```js
* gtag('event', 'video_auto_play_start', {
* 'event_label': 'My promotional video',
* 'event_category': 'video_auto_play'
* });
* ```
*
* @param action 'video_auto_play_start'
* @param options event options (category, label, value, interaction, [custom dimensions] options)
*/
event(action: GaActionEnum | string, options?: IGoogleAnalyticsServiceEvent): void;
/**
* Send a page view event. This is the same as:
*
* ```js
* gtag('config', 'GA_TRACKING_ID', {
* 'page_title' : 'Homepage',
* 'page_path': '/home'
* });
* ```
*
* The tracking ID is injected automatically by Inject Token NGX_GOOGLE_ANALYTICS_SETTINGS_TOKEN
*
* @param path /home
* @param options pageView options (title, location, [custom dimensions] options)
*/
pageView(path: string, options?: IGoogleAnalyticsServicePageView): void;
/**
* Send an event to report a App Page View. This is the same as:
*
* ```js
* gtag('event', 'screen_view', {
* 'app_name': 'myAppName',
* 'screen_name' : 'Home'
* });
*
* ```
*
* @param screen 'screen_name'
* @param appName 'app_name'
* @param options appView options (appId, appVersion, installerId)
*/
appView(screen: string, appName: string, options?: IGoogleAnalyticsServiceAppView): void;
/**
* Defines persistent values on GoogleAnalytics
*
* @see https://developers.google.com/analytics/devguides/collection/gtagjs/setting-values
*
* ```js
* gtag('set', {
* 'currency': 'USD',
* 'country': 'US'
* });
* ```
*/
set(options: Record<string, Primitive>): void;
/**
* Send an event to GA to report an application error. This is the same as:
*
* ```js
* gtag('event', 'exception', {
* 'description': 'error_description',
* 'fatal': false // set to true if the error is fatal
* });
* ```
*
* @param description 'error_description'
* @param fatal set to true if the error is fatal
*/
exception(description?: string, fatal?: boolean): void;
private throw;
private toKeyValue;
static ɵfac: i0.ɵɵFactoryDeclaration<GoogleAnalyticsService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<GoogleAnalyticsService>;
}