Google Analytics not tracking views in IOS Ionic 3 Application with GTAG.js

巧了我就是萌 提交于 2020-07-09 14:52:11

问题


I'm setting up Google Analytics in my application, I already track all events and pages.

When I look the Google Analytics, the android is working perfectly, otherwise the iOS is not tracking any view or event.

I tried change the iOS version, but nothing change.

<script src="https://www.googletagmanager.com/gtag/js?id=UA-XXX-1"></script>

<script>

  window.dataLayer = window.dataLayer || [];

  function gtag(){dataLayer.push(arguments);}

  gtag('js', new Date());

  gtag('config', 'UA-XXX-1', {
    'page_title' : "Ionic App",
    'page_path': 'OpenApp'
  });

</script>
declare let gtag: Function;

@Injectable()
export class GoogleAnalyticsProvider {

  trackPagesHandler(view) {

    let pagePath = view.instance.constructor.name;

    gtag('config', 'UA-XXX-1', {
      'page_title': "Ionic App",
      'page_path': pagePath
    });

  }

  trackEventHandler(eventCategory, eventAction, eventLabel) {

    const eventData = {
      event_category: eventCategory,
      event_label: eventLabel,
    };

    gtag('event', eventAction, eventData);

  }

}

</script>
this.app.viewDidEnter.subscribe((view: ViewController) => this.ga.trackPagesHandler(view));

I want to know a way to make works in both platform.

来源:https://stackoverflow.com/questions/57222552/google-analytics-not-tracking-views-in-ios-ionic-3-application-with-gtag-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!