Skip to content
This repository was archived by the owner on Oct 14, 2024. It is now read-only.
This repository was archived by the owner on Oct 14, 2024. It is now read-only.

ERROR ReferenceError: gtag is not defined when running npm run build:prerender #681

Description

@kuncevic

Hi there, thank you guys for a great universal starter project that was really useful to me.

I just added the gtag to be able to track the google analytics router change event in my application that based on the universal starter.

Then when I run npm run build:prerender that giving me an error ERROR ReferenceError: gtag is not defined

I modified the starter with this code :

export class AppComponent implements OnInit {
  constructor(public router: Router) {}

  ngOnInit() {
    const navEndEvent$ = this.router.events.pipe(filter(e => e instanceof NavigationEnd));
    navEndEvent$.subscribe((e: NavigationEnd) => {
      gtag('config', 'UA-xxxxxxxxx-x', { page_path: e.urlAfterRedirects });
    });
  }
}

So you can reproduce it by cloning https://github.com/kuncevic/universal-starter

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions