Google analytics 如何将谷歌分析添加到jhipster产品中?
我遵循了本教程: 当我运行npm start时,它似乎工作正常,但当我构建生产文件或运行/gradlew时,它就不再工作了。没有错误或任何东西 你知道为什么吗 要复制,只需生成新的jhipster应用程序并修改2个文件: 修改的文件:Google analytics 如何将谷歌分析添加到jhipster产品中?,google-analytics,jhipster,Google Analytics,Jhipster,我遵循了本教程: 当我运行npm start时,它似乎工作正常,但当我构建生产文件或运行/gradlew时,它就不再工作了。没有错误或任何东西 你知道为什么吗 要复制,只需生成新的jhipster应用程序并修改2个文件: 修改的文件: \src\main\webapp\index.html 从'***'导入{***}; 声明让gtag:任何; ... ngOnInit():void{ this.router.events.subscribe(事件=>{ if(NavigationEnd的事件
\src\main\webapp\index.html
从'***'导入{***};
声明让gtag:任何;
...
ngOnInit():void{
this.router.events.subscribe(事件=>{
if(NavigationEnd的事件实例){
this.updateTitle();
gtag('config','UA-******-1',{'page_path':event.urlaftredirects});浏览器控制台中没有错误?浏览器控制台中没有错误?
...
<!-- jhipster-needle-add-resources-to-root - JHipster will add new resources here -->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-*******-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
</script>
</head>
src\main\webapp\app\layouts\main\main.component.ts
import { *** } from '***';
declare let gtag: any;
...
ngOnInit(): void {
this.router.events.subscribe(event => {
if (event instanceof NavigationEnd) {
this.updateTitle();
gtag('config', 'UA-******-1', {'page_path':event.urlAfterRedirects}); <--
}
...