简体   繁体   中英

How to change default `Page View` name

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM