• Version 10.0.0
  • Published
  • 1.3 MB
  • 1 dependency
  • MIT license


npm i angulartics2
yarn add angulartics2
pnpm add angulartics2


Vendor-agnostic web analytics for Angular2 applications






    class AngularRouterTracking

    class AngularRouterTracking implements RouterlessTracking {}
    • Track Route changes for applications using Angular's default router


    constructor(router: any, location: any);

      method prepareExternalUrl

      prepareExternalUrl: (url: string) => string;

        method trackLocation

        trackLocation: (settings: any) => any;

          class Angulartics2

          class Angulartics2 {}


            constructor(tracker: RouterlessTracking, setup: Angulartics2Token);

              property eventTrack

              eventTrack: any;

                property exceptionTrack

                exceptionTrack: any;

                  property pageTrack

                  pageTrack: any;

                    property setAlias

                    setAlias: any;

                      property setSuperProperties

                      setSuperProperties: any;

                        property setSuperPropertiesOnce

                        setSuperPropertiesOnce: any;

                          property settings

                          settings: Angulartics2Settings;

                            property setUsername

                            setUsername: any;

                              property setUserProperties

                              setUserProperties: any;

                                property setUserPropertiesOnce

                                setUserPropertiesOnce: any;

                                  property userTimings

                                  userTimings: any;

                                    method clearUrl

                                    protected clearUrl: (url: string) => string;
                                    • Removes id's from tracked route. EX: /project/12981/feature becomes /project/feature

                                      Parameter url

                                      current page path

                                    method filterDeveloperMode

                                    filterDeveloperMode: <T>() => any;
                                    • filters all events when developer mode is true

                                    method matchesExcludedRoute

                                    protected matchesExcludedRoute: (url: string) => boolean;
                                    • Use string literals or regular expressions to exclude routes from automatic pageview tracking.

                                      Parameter url


                                    method trackUrlChange

                                    protected trackUrlChange: (url: string) => void;

                                      class Angulartics2Module

                                      class Angulartics2Module {}

                                        method forRoot

                                        static forRoot: (settings?: Partial<Angulartics2Settings>) => any;

                                          class Angulartics2On

                                          class Angulartics2On implements AfterContentInit {}


                                            constructor(elRef: any, angulartics2: Angulartics2, renderer: any);

                                              property angulartics2On

                                              angulartics2On: string;

                                                property angularticsAction

                                                angularticsAction: string;

                                                  property angularticsCategory

                                                  angularticsCategory: string;

                                                    property angularticsLabel

                                                    angularticsLabel: string;

                                                      property angularticsProperties

                                                      angularticsProperties: any;

                                                        property angularticsValue

                                                        angularticsValue: string;

                                                          method eventTrack

                                                          eventTrack: (event: Event) => void;

                                                            method ngAfterContentInit

                                                            ngAfterContentInit: () => void;

                                                              class Angulartics2OnModule

                                                              class Angulartics2OnModule {}

                                                                class DefaultConfig

                                                                class DefaultConfig implements Angulartics2Settings {}

                                                                  property appInsights

                                                                  appInsights: {};

                                                                    property developerMode

                                                                    developerMode: boolean;

                                                                      property ga

                                                                      ga: {};

                                                                        property gst

                                                                        gst: {};

                                                                          property gtm

                                                                          gtm: {};

                                                                            property pageTracking

                                                                            pageTracking: {
                                                                            autoTrackVirtualPages: boolean;
                                                                            basePath: string;
                                                                            excludedRoutes: any[];
                                                                            clearIds: boolean;
                                                                            clearHash: boolean;
                                                                            clearQueryParams: boolean;
                                                                            idsRegExp: RegExp;

                                                                              class RouterlessTracking

                                                                              class RouterlessTracking {}

                                                                                method prepareExternalUrl

                                                                                prepareExternalUrl: (url: string) => string;

                                                                                  method trackLocation

                                                                                  trackLocation: (settings: Angulartics2Settings) => any;


                                                                                    interface Angulartics2Settings

                                                                                    interface Angulartics2Settings {}

                                                                                      property appInsights

                                                                                      appInsights: Partial<AppInsightsSettings>;

                                                                                        property developerMode

                                                                                        developerMode: boolean;
                                                                                        • Disable page tracking

                                                                                        property ga

                                                                                        ga: Partial<GoogleAnalyticsSettings>;

                                                                                          property gst

                                                                                          gst: Partial<GoogleGlobalSiteTagSettings>;

                                                                                            property gtm

                                                                                            gtm: Partial<GoogleTagManagerSettings>;

                                                                                              property pageTracking

                                                                                              pageTracking: Partial<PageTrackingSettings>;

                                                                                                interface Angulartics2Token

                                                                                                interface Angulartics2Token {}

                                                                                                  property settings

                                                                                                  settings: Partial<Angulartics2Settings>;

                                                                                                    interface AppInsightsSettings

                                                                                                    interface AppInsightsSettings {}

                                                                                                      property userId

                                                                                                      userId: string;

                                                                                                        interface EventTrack

                                                                                                        interface EventTrack {}

                                                                                                          property action

                                                                                                          action: string;

                                                                                                            property properties

                                                                                                            properties: any;

                                                                                                              interface GoogleAnalyticsSettings

                                                                                                              interface GoogleAnalyticsSettings {}

                                                                                                                property additionalAccountNames

                                                                                                                additionalAccountNames: string[];
                                                                                                                • array of additional account names (only works for analyticsjs)

                                                                                                                property anonymizeIp

                                                                                                                anonymizeIp: boolean;

                                                                                                                  property transport

                                                                                                                  transport: string;
                                                                                                                  • see

                                                                                                                  property userId

                                                                                                                  userId: any;

                                                                                                                    interface GoogleGlobalSiteTagSettings

                                                                                                                    interface GoogleGlobalSiteTagSettings {}

                                                                                                                      property anonymizeIp

                                                                                                                      anonymizeIp?: boolean;

                                                                                                                        property customMap

                                                                                                                        customMap?: {
                                                                                                                        [key: string]: string;

                                                                                                                          property trackingIds

                                                                                                                          trackingIds: any;

                                                                                                                            property userId

                                                                                                                            userId?: any;

                                                                                                                              interface GoogleTagManagerSettings

                                                                                                                              interface GoogleTagManagerSettings {}

                                                                                                                                property userId

                                                                                                                                userId: any;

                                                                                                                                  interface PageTrack

                                                                                                                                  interface PageTrack {}

                                                                                                                                    property path

                                                                                                                                    path: string;

                                                                                                                                      interface PageTrackingSettings

                                                                                                                                      interface PageTrackingSettings {}

                                                                                                                                        property autoTrackVirtualPages

                                                                                                                                        autoTrackVirtualPages: boolean;

                                                                                                                                          property basePath

                                                                                                                                          basePath: string;

                                                                                                                                            property clearHash

                                                                                                                                            clearHash: boolean;
                                                                                                                                            • drop contents of url after hash marker /callback#authcode=1234 -> /callback

                                                                                                                                            property clearIds

                                                                                                                                            clearIds: boolean;
                                                                                                                                            • drop ids from url /sections/123/pages/456 -> /sections/pages

                                                                                                                                            property clearQueryParams

                                                                                                                                            clearQueryParams: boolean;
                                                                                                                                            • drop query params from url /sections/123/pages?param=456&param2=789 -> /sections/123/pages

                                                                                                                                            property excludedRoutes

                                                                                                                                            excludedRoutes: (string | RegExp)[];

                                                                                                                                              property idsRegExp

                                                                                                                                              idsRegExp: RegExp;
                                                                                                                                              • used with clearIds, define the matcher to clear url parts

                                                                                                                                              interface TrackNavigationEnd

                                                                                                                                              interface TrackNavigationEnd {}

                                                                                                                                                property url

                                                                                                                                                url: string;

                                                                                                                                                  interface UserTimings

                                                                                                                                                  interface UserTimings {}

                                                                                                                                                  property timingCategory

                                                                                                                                                  timingCategory: string;
                                                                                                                                                  • A string for categorizing all user timing variables into logical groups (e.g. 'JS Dependencies').

                                                                                                                                                  property timingLabel

                                                                                                                                                  timingLabel?: string;
                                                                                                                                                  • A string that can be used to add flexibility in visualizing user timings in the reports (e.g. 'Google CDN').

                                                                                                                                                  property timingValue

                                                                                                                                                  timingValue: number;
                                                                                                                                                  • The number of milliseconds in elapsed time to report to Google Analytics (e.g. 20).

                                                                                                                                                  property timingVar

                                                                                                                                                  timingVar: string;
                                                                                                                                                  • A string to identify the variable being recorded (e.g. 'load').

                                                                                                                                                  Package Files (9)

                                                                                                                                                  Dependencies (1)

                                                                                                                                                  Dev Dependencies (0)

                                                                                                                                                  No dev dependencies.

                                                                                                                                                  Peer Dependencies (3)


                                                                                                                                                  To add a badge like this badgeto your package's README, use the codes available below.

                                                                                                                                                  You may also use to create a custom badge linking to

                                                                                                                                                  • Markdown
                                                                                                                                                  • HTML
                                                                                                                                                    <a href=""><img src="" alt=""></a>