angulartics / angulartics2

Vendor-agnostic analytics for Angular2 applications.
MIT License
1.01k stars 193 forks source link

GA events send incorrect `dp` page argument when `pageTracking` config set #359

Open sruck opened 5 years ago

sruck commented 5 years ago

For support questions, please consider using Gitter - Chat

I'm submitting a ...

Summary When any non-default pageTracking is configured for Angulartics2 page views, the corresponding clearUrl page handling is not applied when processing eventTrack triggers. As a result, GA events report the simple hash substring URL if an explicit page property has not been set on the event binding, which overrides the originally configured page view report in Google Analytics Content dashboard. This results in cleared IDs and QueryParams still appearing in GA whenever events are fired.

Reproduction info and code points

  1. App module provider config:

    providers: [
    {
      provide: ANGULARTICS2_TOKEN, useValue: {
        settings: {
          pageTracking: {
            clearIds: true,
            clearQueryParams: true
          }
        } as Angulartics2Settings
      }
    },
    ],
  2. Configure an angulartics2On="click" button in the app

  3. Observe the GA PageView request args

    t: pageview
    dl: https://localhost/sampleApp/
    dp: /example-route
  4. Observe the GA Event request args

    t: event
    dl: https://localhost/sampleApp/
    dp: /example-route/12345?queryArg=example

Related code points:

Package Version

@angular-devkit/architect 0.801.3 @angular-devkit/build-angular 0.801.3 @angular-devkit/build-optimizer 0.801.3 @angular-devkit/build-webpack 0.801.3 @angular-devkit/core 8.1.3 @angular-devkit/schematics 8.3.5 @angular/cdk 8.2.0 @angular/cli 8.3.5 @angular/common 8.1.3 @angular/http 7.2.15 @angular/material 8.2.0 @ngtools/webpack 8.1.3 @schematics/angular 8.3.5 @schematics/update 0.803.5 rxjs 6.4.0 typescript 3.4.5 webpack 4.35.2