How to change default `Page View` name

511 views Asked by At

Is it possible to change default name of page view event tracked after importing Angulartics2GoogleTagManager in app.component? Rigth now its Page View and I need to change the name.

1

There are 1 answers

1
XTOTHEL On BEST ANSWER

If you want to change the name of the event, you would need to modify the angulartic2 GTM package itself. Specifically this file: https://github.com/angulartics/angulartics2/blob/master/src/lib/providers/gtm/gtm.ts

The datalayer.push for angulartics2.pageTrack looks like this:

dataLayer.push({
        'event': 'Page View',
        'content-name': path,
        'userId': this.angulartics2.settings.gtm.userId
      });

If you want to change it, just change the 'event' key value.

To track pageviews however:

You need to:

  1. create a GTM custom event trigger for the "Page View" event
  2. create a GTM datalayer variable to capture the "content-name" value
  3. create a GTM tag for Google Analytics with the custom fields "page" set to the datalayer variable created in step 2 and trigger on the trigger created on step 1