问题
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