After building a basic app with two pages (quotes-list and quotes-detail) where clicking a name on the former you edit a text on the latter, run the app on a real device and go through GA, trying to get some statistics about the two tracked pages, but all I can see is nothing. Anyone could help me, please? I'd appreciate it so much...
app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
//import { SplashScreen } from '@ionic-native/splash-screen';
//import { StatusBar } from '@ionic-native/status-bar';
import { MyApp } from './app.component';
import { QuotesListPage } from '../pages/quotes-list/quotes-list';
import { QuotesDetailPage } from '../pages/quotes-detail/quotes-detail';
import { HttpModule } from '@angular/http';
import { GoogleAnalytics } from '@ionic-native/google-analytics';
@NgModule({
declarations: [
MyApp,
QuotesListPage,
QuotesDetailPage
],
imports: [
BrowserModule,
HttpModule,
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
QuotesListPage,
QuotesDetailPage
],
providers: [
GoogleAnalytics,
{provide: ErrorHandler, useClass: IonicErrorHandler}
]
})
export class AppModule {}
quotes-list.ts
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams, Platform } from 'ionic-angular';
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';
import {QuotesDetailPage} from '../quotes-detail/quotes-detail';
import { GoogleAnalytics } from '@ionic-native/google-analytics';
/**
* Generated class for the QuotesListPage page.
*
* See https://ionicframework.com/docs/components/#navigation for more info on
* Ionic pages and navigation.
*/
@IonicPage()
@Component({
selector: 'page-quotes-list',
templateUrl: 'quotes-list.html',
})
export class QuotesListPage {
quotesList = [];
filteredQuotes = [];
isfiltered: boolean ;
constructor(platform: Platform, private http:Http, public navCtrl: NavController, public navParams: NavParams, public googleanalytics: GoogleAnalytics) {
this.isfiltered = false;
this.http.get('quotes.json')
.map(res => res.json())
.subscribe(
data => {
this.quotesList = data.quotes;
},
err => console.log("error is "+err), // error
() => console.log('read quotes Complete '+ this.quotesList) // complete
);
platform.ready().then(() => {
googleanalytics.trackView("Quotes List");
});
}
ionViewDidLoad() {
console.log('ionViewDidLoad QuotesListPage');
}
searchQuotes(event) {
if(event.target.value.length > 2) {
var filteredJson = this.quotesList.filter(function (row) {
if(row.author.indexOf(event.target.value) != -1) {
return true
} else {
return false;
}
});
this.isfiltered = true;
this.filteredQuotes = filteredJson;
}
}
itemTapped(event, quote) {
console.log(quote);
this.navCtrl.push(QuotesDetailPage, {
quote: quote
});
}
}
quotes-detail.ts
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams, Platform } from 'ionic-angular';
import { GoogleAnalytics } from '@ionic-native/google-analytics';
/**
* Generated class for the QuotesDetailPage page.
*
* See https://ionicframework.com/docs/components/#navigation for more info on
* Ionic pages and navigation.
*/
@IonicPage()
@Component({
selector: 'page-quotes-detail',
templateUrl: 'quotes-detail.html',
})
export class QuotesDetailPage {
quoteDetail: {quote:'', author:''};
constructor(public navCtrl: NavController, public navParams: NavParams, public googleanalytics: GoogleAnalytics) {
this.quoteDetail = navParams.get('quote');
googleanalytics.trackView("Quotes Detail");
}
ionViewDidLoad() {
console.log('ionViewDidLoad QuotesDetailPage');
}
}
app.component.ts
import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';
//import { StatusBar } from '@ionic-native/status-bar';
//import { SplashScreen } from '@ionic-native/splash-screen';
import { QuotesListPage } from '../pages/quotes-list/quotes-list';
import { GoogleAnalytics } from '@ionic-native/google-analytics';
@Component({
templateUrl: 'app.html'
})
export class MyApp {
rootPage:any = QuotesListPage;
constructor(platform: Platform, googleanalytics: GoogleAnalytics) {
platform.ready().then(() => {
googleanalytics.debugMode();
googleanalytics.startTrackerWithId("UA-XXXXXXXXX-1");
googleanalytics.enableUncaughtExceptionReporting(true).then((_success) => {
console.log("Successful enabling of uncaught exception reporting "+_success)}).catch((_error) => {
console.log("error occured "+_error)
});
});
}
}