UNPKG

ngx-google-analytics

Version:

A simple ng-9 wrapper to load Google Analytics dependency by angular way

100 lines (99 loc) 3.32 kB
import { IGoogleAnalyticsSettings } from '../interfaces/i-google-analytics-settings'; import { GaActionEnum } from '../enums/ga-action.enum'; 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(); constructor(settings: IGoogleAnalyticsSettings, _document: any, _gtag: GtagFn); private throw; /** @todo Change this to `Object.fromEntity()` in the future... */ private toKeyValue; /** * Call native GA Tag */ gtag(...args: any[]): void; /** * Send an event trigger to GA. It is the same as call: * ```js * gtag('event', 'video_auto_play_start', { * 'event_label': 'My promotional video', * 'event_category': 'video_auto_play' * }); * ``` * * @param action 'video_auto_play_start' * @param category 'video_auto_play' * @param label 'My promotional video' * @param value An value to measure something * @param interaction If user interaction is performed */ event(action: GaActionEnum | string, category?: string, label?: string, value?: number, interaction?: boolean, options?: Object): void; /** * Send an 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 title Homepage * @param location '{ page_location }' * @param options '{ ... custom dimentions }' */ pageView(path: string, title?: string, location?: string, options?: Object): void; /** * Send an event to report a App Page View. It is the same as * * ```js * gtag('event', 'screen_view', { * 'app_name': 'myAppName', * 'screen_name' : 'Home' * }); * * ``` * * @param screen 'screen_name' * @param appName 'app_name' * @param appId 'app_id' * @param appVersion 'app_version' * @param installerId 'app_installer_id' */ appView(screen: string, appName: string, appId?: string, appVersion?: string, installerId?: string): 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: Array<any>): void; /** * Send an event to GA to report an application error. It 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; static ɵfac: i0.ɵɵFactoryDeclaration<GoogleAnalyticsService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<GoogleAnalyticsService>; }