@c4uno/ionic-event-tracking
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

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

Package Sidebar

Install

npm i @c4uno/ionic-event-tracking

Weekly Downloads

1

Version

1.1.0

License

MIT

Unpacked Size

20.2 kB

Total Files

26

Last publish

Collaborators

  • c4uno_agalicia
  • victor.aguilar