Ionic

Please note that Ionic capacitor is not supported currently.

 
Integration of Marketo Cordova Plugin

Prerequisites

  1. Add an application in Marketo Admin (obtain your application Secret Key and Munchkin Id).
  2. Setup Push Notifications ( iOS | Android ).
  3. Install Ionic & Cordova CLI.

Installation Instructions

1. Setup Marketo Ionic Plugin

  • Assuming the Cordova CLI is installed, go to your Ionic application directory and run the following command to add the Marketo Plugin into your application:

$ ionic plugin add https://github.com/Marketo/PhoneGapPlugin.git --variable APPLICATION_SECRET_KEY="YOUR_APPLICATION_SECRET"

  • To confirm that the plugin has been added to the application, run following command:

$ ionic plugin list
com.marketo.plugin 0.X.0 "MarketoPlugin"

Migrate to Newer Version (Optional)

  • To remove an existing plugin, run the following command:

$ ionic plugin remove com.marketo.plugin

  • To re-add the plugin, run the following command:

$ ionic plugin add https://github.com/Marketo/PhoneGapPlugin.git --variable APPLICATION_SECRET_KEY="YOUR_APPLICATION_SECRET"

2. Enable Push Notifications in xCode

  1. Turn on push notification capability in xCode project.notification_capability

3. Track Push Notifications

Paste the following code inside the application:didFinishLaunchingWithOptions: function.


4. Initialize Marketo Framework

To ensure that the Marketo framework is initiated on app startup, add the following code under the onDeviceReady function in your main JavaScript file.

Please note that we need to pass “ionicCordova” as framework type for Ionic Cordova Apps.

 

Syntax

Parameters

  • Success Callback : function to execute if Marketo framework initializes successfully.
  • Failure Callback : function to execute if Marketo framework fails to initialize.
  • MUNCHKIN ID : Munchkin ID received from Marketo at time of registration.
  • SECRET KEY : Secret Key received from Marketo at time of registration.

5. Initialize Marketo Push Notification

To make sure that Marketo push notification gets initiated add the following code after the initialize function in your main JavaScript file.

Syntax

Parameters

  • Success Callback : function to execute if Marketo push notification initializes successfully.
  • Failure Callback : function to execute if Marketo push notification fails to initialize.
  • GCM_PROJECT_ID : GCM Project ID found in Google Developers Console after creating app.

The token can also be unregistered on logout.

Associate Lead

You can create a Marketo Lead by calling the associateLead function.

Syntax

Parameters

  • Success Callback : function to execute if Marketo framework associates the lead successfully.
  • Failure Callback : function to execute if Marketo framework fails to associate the lead.
  • Lead Data : lead data in JSON string format.

Example

Report Action

You can report any user performed action by calling the reportaction function.

Syntax

Parameters

  • Success Callback : function to execute if Marketo framework reports action successfully.
  • Failure Callback : function to execute if Marketo framework fails to report action.
  • Action Name : action name.
  • Action Data : action data in JSON string format.

Example

Session Reporting

Bind the “pause” and “resume” event types as shown below to report Start and Stop events.  This is used to track time spent in your mobile application. Note: this is required in Android.

Creating Leads

There are three ways to create leads from a hybrid app:

  1. Marketo MME SDK
  2. Marketo REST API
  3. Form Submit

Depending on the method used, a newly created lead will be recognized by different triggers and filters. Leads created using the MME SDK or REST API appear in the “Lead Created” triggers and filters. Leads created by form submissions appear in the “Fills Out Form” triggers and filters.

The best practice is to remain consistent with the method used by the Web app when creating leads. If you already have a Web app that uses form submission as the mechanism to create leads, then use that same mechanism when creating leads in your hybrid app. If you already have a Web app that uses our REST API as the mechanism to create leads, then use that same mechanism when creating leads in your hybrid app. In cases where you use neither form submission nor REST API as a mechanism to create leads in your Web app, you can consider using the MME SDK to create leads in Marketo.