@c4uno/ionic-event-tracking
v1.1.0
Published
Integration with Goolge Analytics and other events trackings
Downloads
23
Readme
Ionic Event Tracking
Integration with event trackings as Google Analytics and Mixpanel.
Requirements
- Ionic 3.9
Installation
npm install --dev @c4uno/ionic-event-tracking
To use Google Analytics install, it is necessary install the Cordova plugin
ionic cordova plugin add cordova-plugin-google-analytics
Use
Import and configure the EventTrackingModule
in you AppModule
import {EventTrackingModule} from "@c4uno/ionic-event-tracking";
@NgModule({
imports: [
EventTrackingModule.forRoot({
enabled: true,
trackingId: '123456'
}),
]
})
To track page view
Use the decorator PageTrack
import {PageTrack} from "@c4uno/ionic-event-tracking";
@PageTrack('Contacto')
export class ContactPage {
}
To track custom events
Use the EventTracking
service
import {EventTracking} from '@c4uno/ionic-event-tracking';
export class LoginPage {
@Input() cellphone: string = '';
@Input() password: string = '';
/**
*
* @param {NavController} navCtrl
* @param {AuthProvider} auth
* @param analyticsService
*/
constructor(private eventTracking: EventTracking) {
}
public login() {
this.eventTracking.trackEvent('login', 'success');
}
}
To track user
You can link a user with the events using
public login() {
this.eventTracking.setUser({name: "Test user", id: 1})
}
The parameter is a open object, that depend of the implementation.
Publication
Run
npm run publish-package