Skip to content

Cordova & Ionic Integration

Requirements

This setup assumes you have already setup your App Key on the Dashboard. Minimum requirements are Ionic 4. Ionic 3.9.2+ is also supported.

Integration Steps

Install Pointzi in your Cordova project. Run this command in a console.

1
cordova plugin add cordova-plugin-pointzi

Put initial code to your device ready or platform ready handler, example:

Cordova

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
$(document).on('deviceready', function deviceIsReady() {
    /*Other Code */
    window.Pointzi.load().then(function () {

         // USER_ID is optional.
         // You can set it later by sending user_id tag. It is string tag.
         window.Pointzi.register(APP_KEY, USER_ID).then(function () {
              // Example of sending a String Tag
              let key = "first_name";
              let value = "My First Name";
              window.Pointzi.tag.string(key, value);
         })
    })
    /*Other Code */
 });

Ionic 4

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
this.platform.ready().then(() => {
    /*Other Code */
    window.Pointzi.load().then(function () {

        // USER_ID is optional.
        // You can set it later by sending user_id tag. It is string tag.
        window.Pointzi.register(APP_KEY, USER_ID).then(function () {
            // Send String Tag
            let key = "first_name";
            let value = "My First Name";
            window.Pointzi.tag.string(key, value);
        })
    })
    /*Other Code */
});

Note

To get your APP_KEY, go to dashboard.pointzi.com, where you can see it's name at the top left of the screen. USER_ID is the name you want to give to your install-id. This name is up to you. For more info visit the Tagging documentation. When you call register method, USER_ID is optional, you can set it later by sending user_id tag, it is string tag.

User Tagging

You can tag users/devices from your SDK in one line of code.

The SDK looks after the details for the device, you just supply the tag key and value:

  • The tag name (key) is what you want to call it. In the example below "Plan-49" is how you will see this in the Pointzi Dashboard.
  • Pointzi supports tags of: string, numeric and datetime. In the example below, the value for "Plan-49" is "Trial-Period".

String Tags

1
2
3
let key = "Plan-49";
let value = "Trial-Period";
window.Pointzi.tag.string(key, value);

Numeric Tags

1
2
3
let key = "BidValue";
let value = 549;
window.Pointzi.tag.numeric(key, value);

Datetime Tags

1
2
3
4
5
6
7
8
9
// Tagging using predefined StreetHawk tag.
let key = "sh_registered";
let value = new Date();
window.Pointzi.tag.datetime(key, value);

// Tagging using custom tag.
let key = "Birthday";
let value = new Date();
window.Pointzi.tag.datetime(key, value);

Increment Tag Value

1
2
let key = "PageVisited";
window.Pointzi.tag.increment(key);

Enable Youtube video

Add this to your config.xml

1
2
3
4
<!-- Add the whitelist plugin -->
<plugin name="cordova-plugin-whitelist" spec="~1.2.0" />
<!-- White list https access to Youtube -->
<allow-navigation href="https://*youtube.com/*"/>