App analytics SDK for IONIC / CORDOVA based applications
App analytics SDK for IONIC based applications
Variable
File
Permissions(optional)
Add your google-services.json to the root of your cordova project before you add the plugin.
<resource-file src="google-services.json" target="app/google-services.json" ></resource-file>
* Under platform “Ios”
From root of application
Using Cordova:
cordova plugin add PATH/Git URL --variable
PLUMB5_ACCOUNT_ID=”YOUR PLUMB5 ID“ —variable
PLUMB5_API_KEY=”YOUR PLUMB5 KEY“ —variable
PLUMB5_BASE_URL=”YOUR PLUMB5 URL“
`ionic` `cordova plugin add` **PATH/Git URL --variable
PLUMB5_ACCOUNT_ID=”YOUR PLUMB5 ID“ —variable
PLUMB5_API_KEY=”YOUR PLUMB5 KEY“ —variable
PLUMB5_BASE_URL=”YOUR PLUMB5 URL“
Using Cordova:
cordova plugin rm cordova-plugin-plumb5
* Please ignore the error after removing the plugin
Using Ionic:
ionic cordova plugin rm cordova-plugin-plumb5
* Please ignore the error after removing the plugin
Add app.component.ts
import { Component } from '@angular/core';
import { Platform } from '@ionic/angular';
import { Router, NavigationStart, ActivatedRoute} from '@angular/router';
declare var cordova: any;
var p5 = cordova.plugins.Plumb5.init();
export class AppComponent {
constructor(
private platform: Platform,
public router: Router,
private pageParameter:ActivatedRoute
) {
this.initializeApp();
p5.setup();
//Plumb5 lifecycle and in-app
this.router.events.forEach((event) => {
if (event instanceof NavigationStart) {
p5.tracking([{ ScreenName: event.url, PageParameter: "" }]); p5.pushResponsePost([{ ScreenName: event.url, PageParameter: "" }]);
}
});
}
initializeApp() {
this.platform.ready().then(() => {
//page navigation listener
document.addEventListener('onPushNotification', (e: any) => {
let routeUrl = e.routeUrl
this.router.navigate([routeUrl]);
});
});
}
User details
var userDetailsJson =[
{
"Name": "demo",
"EmailId": "demo@demo.com",
"PhoneNumber": "987654321",
"LeadType": 1,
"Gender": "Male",
"Age": "2020-01-27T06:12:01.051Z",
"AgeRange": "10-89",
"MaritalStatus": "Married",
"Education": "MCA",
"Occupation": "SE",
"Interests": "Eating",
"Location": "Bangalore"
//Add extra parameters
"key":"value"
}
]
p5.setUserDetails(userDetailsJson);
Event
<ion-button color="primary" (click)="btn1()">Event Post</ion-button>
* **Component.ts**
```smalltalk
btn1(){
let eventDetailsJson =[
{
"Type": "Button",
"Name": "Event Post",
"Value": 1
}
]
p5.eventPost(eventDetailsJson);
}
```