Install Pendo in hybrid apps

Last updated:

This article explains how to install Pendo in hybrid apps built with web technologies, such as Cordova, Ionic, and Capacitor. Hybrid apps contain both mobile and web components, such as WebViews, to load web pages inside an app. For other types of hybrid apps, see Use Pendo with hybrid apps.

For Cordova and Ionic apps, use the Pendo web installation snippet with a web app key to collect analytics and show guides in the web layer. Pendo doesn't provide a mobile SDK for Cordova or Ionic. For more information about installing the web snippet, see Developer's guide to implementing Pendo using the install script.

Native functionality in Cordova and Ionic apps supports Track Events only. You must instrument these events in your application code; Pendo doesn't automatically capture native interactions or show guides in native components.

Important: If you also track visitors in other applications, use the same Visitor IDs, Account IDs, and metadata keys and values across installations to keep visitor journeys consistent.

Install Pendo in Cordova applications

Cordova is an open-source framework for building hybrid mobile apps. Its web pages are served from a local web server running on the iOS or Android device. The app is on the web and opens a web view in the app. 

Typically, Cordova applications are built around a central web application. If you want to install Pendo in a Cordova application, there are a few caveats to consider relating to:

  • Building to the browser
  • Tagging pages 
  • Track native device functionality

Build to browser

As with most applications, Pendo is installed using a JavaScript install script. Consequently, Cordova applications must be accessible in a web browser so that you can tag Pages and Features and build in-app guides with the Visual Design Studio.  

You can do this using the browser platform provided by Cordova's CLI. 

  1. Add the browser platform to your Cordova application: cordova platform add browser.
  2. Build your web application for the browser platform: cordova build browser.

This results in a static build of your web application created at /<path-to-application>/platforms/browser/www. You must then host this build in a location that’s accessible to the Pendo users who build guides or tag Pages and Features.

Tag Pages

Because Cordova applications can be built for several different platforms, Page rules must account for all intended platforms. For example, the following shows the Suggested Pages for a sample Cordova application.

Cordova_Suggested_Page.png

In this example, two suggested Pages both point to the same page (index.html). This is because the browser and iOS platforms on which this application runs serve the same Page at different URLs. 

To account for scenarios like this, manually add any additional platform URLs after following the standard procedure for tagging the browser's platform page. Go to the tagged Page in Pendo and select Add Rule. For more detailed instructions, see Page tagging. 

In the example, below, //*/index.html captures the browser platform URL, and //*/*/*/*/*/*/*/*/*/index.html captures the iOS platform URL.

Cordova_Page_Rules.png

Track native device functionality

Since Pendo is installed in the web application layer of a Cordova application, no activity is captured in the native portion of the application. 

For example, if your Cordova application with Pendo installed contains a button that launches the device's native camera application, Pendo only captures clicks on that button and not any interactions that occur within the camera application.

Cordova_activity_capture_example.png

If you require visibility into native device functionality, Track Events can be instrumented as needed in the callback functions provided by the Cordova API. Below is an example of instrumenting Track Events to capture a photo failure.

// EXAMPLE CODE PROVIDED AS IS WITH NO WARRANTY OR SLA


function cameraSuccess() {
  // Code to execute on successful photo
}
function cameraFailure() {
  // Code to execute on failed photo

  // Send camera-error track event to Pendo to track camera failures
  pendo.track("camera-error", {
    model: device.model,
    platform: device.platform,
    version: device.version,
  });
}
navigator.camera.getPicture(cameraSuccess, cameraFailure);
Was this article helpful?
0 out of 0 found this helpful