Ionic implementation not firing
See original GitHub issueI’m trying to track app start (and other views) but nothing shows up on Google Analytics, and no errors are reported on the console
This is the code I’m using on app.component.ts
...
import { GoogleAnalytics } from '@ionic-native/google-analytics';
...
const GA_TRACKING_ID = 'UA-XXXXXXXXX-X';
const GA_TRACKING_DISPATCH = 3; // default 30, doesn't work either
...
export class MyApp implements OnInit {
...
constructor(
...
private ga: GoogleAnalytics,
) {}
ngOnInit() {
this.platform.ready().then(() => {
console.log('platform ready');
...
if (this.platform.is('cordova')) {
console.log('platform is cordova');
...
this.initGoogleAnalytics();
}
});
}
private initGoogleAnalytics() {
console.log('registering tracker');
this.ga
.startTrackerWithId(GA_TRACKING_ID, GA_TRACKING_DISPATCH)
.then(() => {
console.log('Google analytics is ready now');
// the component is ready and you can call any method here
this.ga.debugMode(); // no debugging info shows up on console
this.ga.setAllowIDFACollection(false); // either true or false doesn't work
this.ga.trackView('start')
.then(a => console.log('tracked start', a))
.catch(e => console.log('tracking start failed', e))
;
})
.catch(e => console.log('Error starting GoogleAnalytics', e));
}
}
The track start command should fire normally, with a dispatch of 3s, it should show up on analytics right away
Log result on console, no errors occured
platform ready
platform is cordova
registering tracker
Google analytics is ready now
tracked start Track Screen: start
For the record, Google Analytics Admin no longer allows registering mobile app tracking without firebase, so I created it as a website, and created a mobile view
I set the domain as https://mobile.website.com
and tried setting the compaign url in trackView
as https://mobile.website.com/start
, and still nothing
I checked the tracking ID, and it’s correct
Info
ionic cli : 4.5.0
ionic : 3.9.2
@ionic/app-scripts : 3.2.1
cordova (Cordova CLI) : 8.0.0
Cordova Platforms : android 7.1.3, browser 5.0.4
Android SDK Tools : 26.1.1
Issue Analytics
- State:
- Created 5 years ago
- Comments:8
Top Results From Across the Web
Ion-range's ion-input event does not fire - Ionic Forum
The root issue is caused by Ionic not having a way of synchronously updating the v-model ref. This results in a (hacky) workaround...
Read more >ionViewWillEnter, ionViewDidEnter not firing - angular
I have a tabbed page on an Ionic app with the default page implementing the ionViewWillEnter method. It used to work fine but...
Read more >Ionic 4 and the Lifecycle Hooks in Angular | by Paul Stelzer
In short: Whenever you wonder, why ngOnDestroy is not firing, just take a look at the DOM inspector and you will see that...
Read more >Is Scroll Trigger working with Ionic 6? - GSAP
I've been trying to implement Gsap with ionic & angular and it seems like just don't work https://lampdigitalcol.web.app/666 ...
Read more >The 9 Most Common Mistakes That Ionic Developers Make
Here are some reasons not to use the Folder-by-Type structure: The number of files in your folders can become vast; Finding all the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ya that fixes it. But if you ever remove a platform using
ionic cordova platform rm android`` and then re-add it using
ionic cordova platform add androidit updates the
package.jsonand
config.xmlfiles so that they are again using
^1.8.6```. I’m not sure how to prevent that from happening.Seems like this 1.8.6 issue has been going on for awhile. No response. No updates so it looks like our best bet is probably to just downgrade and make sure Ionic doesn’t automatically update it to 1.8.6. Rack another up one for Ionic Native. 👎