Getting Started

Learn more about adding pyze to your pega application, initializing it in your pega application, and optionally, using events . The Pyze SDK supports all pega platform versions.

1. Get Pyze App Key

See instructions to get a Pyze App Key for your new app.

2. Install the Pyze SDK

Installing Pyze Analytics for Pega is simple, and can requires Pega web analytics component as dependency.

Download Pyze component and Pega Web analytics component

a. Download Pyze component from the github releases

b. Download the Pega component fromm the pega marketplace

Install the components.

  • Open your Application form. (Application -> Definition)

  • Click Manage components.

  • Select Install new and select the zip file that includes the component.

  • Optional: Browse for components on the Pega Exchange site:
    • Click Browse Apps and Components to open the Pega Exchange site to search for other components.

    • Browse the available components. When you find a component to add to your application, follow the instructions on the component page to download the component zip file to your system.

    • Return to your application, and then select the component zip file.

  • Click Open.

  • Select Enabled to enable the new component for this application.
  • Click OK.

For more information check the link : Installing Component

3. Initialize Pyze component

To initialize Pyze component open Data-Admin-System-Settings by going to App tab and searching for Data-Admin-System-Settings as shown below.

Once you add the Pyze App key, you are ready see the data in Pyze Dashboard

Build and Go!

You have enabled all screen flow funnels, loyalty, cohort and churn analysis, Intelligence data explorations, Growth Automation, auto segmentation, and much more. Use your app with the Pyze SDK and you should see data on growth.pyze.com.

Add Events

See a detailed Events Overview here.

Pyze has made it easy for you to capture events. We support custom and timed events.

Custom Event Handling

We support custom events that can be used to track any event within the pega application and can be called with or without attributes. See postCustomEvent and postCustomEventWithAttributes method in the Pyze class (See here).

1. Add Pyze custom event.

Pyze custom event can be called from Run Scripts in pega.

Adding Run Script action

  • Add a Run script to button action as shown below image
  • Pass the below snippet as Function Name
    "PyzeEvents.postCustomEvent"
    
  • Add the paramter to the run script action as the event name as shown below

2. Add Pyze custom event with attributes.

  • Pyze API to send custom attributes accepts the attributes in JSON format.
  • Create a HTML Fragment by going to Records -> Technical -> HTML Fragment
  • Add a script tag and define a javascript function to be invoked from the Run script as shown below.

  <script>
  function postCustomEventWithAttrbutes(){
      var attributes = {};
      attributes["screen"] = "Home";
      attributes["seconds spent"] = "50";
      PyzeEvents.postCustomEventWithAttributes("Blog Read", attributes);
  }

  </script>
  • Finally invoke the postCustomEventWithAttrbutes function from the Run Script. Don’t use double inverted quotes while calling the function.

3. Timed Events

Pyze has made it easy for you to capture duration between events. Pyze supports timed events using following API’s

  • startTimerForEvent - Use this API start timer for perticular event by passing the event name attribute.

  • postTimedEvent - Use this API to end timer and post the event with duration. This API accepts event name attribute. You can also pass attributes as additional parameter as shown in the example below


//Start timer for event
PyzeEvents.startTimerForEvent("Screen Load Time");

//Post timed event. 
//Note : The event name attribute for the `startTimerForEvent` and  `postTimedEvent` should match.
PyzeEvents.postTimedEvent("Screen Load Time");

//Post timed event API when you want to send additional attributes
var customAttributes = {};
customAttributes["device"] = "iMac";
customAttributes["location"] = "CA";
PyzeEvents.postTimedEventWithAttributes("Screen Load Time", customAttributes);

4. User Profiles

Pyze provides ways to segment data for each logged in user. You can use the following API’s to manage user profiles within your app.

Set User Profiles

Use the following API to set user profiles. API accepts unique UserId for each individual users, pyzeProfileAttributes and customProfileAttributes

//Create Pyze Profile Attributes object
var pyzeProfileAttributes = {
   "email_id"        : "xyz@abc.com",
   "date_of_birth"   : "1984-06-01",
   "first_name"      : "John",
   "last_name"       : "Jacobs"
}
//Create Custom Profile Attributes object
var customProfileAttributes = {
   "age"       : 29,
   "pincode"   : "23200",
   "city"      : "XYZ"
}
//Call the setUserProfile API
PyzeIdentity.setUserProfile(userId,pyzeProfileAttributes,customProfileAttributes);

Following are the possible Pyze user profile attributes.

Pyze User Profile Field Name Data Type/Description
background (string) User background, biography or historical data
country (string) Country codes must be sent in the ISO-3166-1 alpha-2 standard.
current_location (object) Format: {“longitude”: -33.991894, “latitude”: 25.243732}
date_of_first_use (date at which the user first used the app) String in ISO 8601 format or in yyyy-MM-dd’T’HH:mm:ss.SSSZ format.
date_of_last_use (date at which the user last used the app) String in ISO 8601 format or in yyyy-MM-dd’T’HH:mm:ss.SSSZ format.
date_of_birth (date of birth) String in format “YYYY-MM-DD”, example: 1984-06-01.
email_id (string) Email Id
email_subscribe (string) Acceptable values are “opt_in” (explicit approval to receive email messages), “opt_out” (explicit denial to email messages), and “subscribed” (neither opted in nor out).
email_hard_bounced Automatically updated when a hard bounce occurs (true or false)
email_spam_reported Automatically updated when a user marks your email as spam, via the ISP (true or false)
facebook_id facebook ID
first_name (string) User’s First name
gender (string) “M”, “F”, “O” (other), “N” (not applicable), “P” (prefer not to say) or “U” (unknown).
home_city (string) User’s Home City
image_url (string) URL of image to be associated with the user
language (string) Require language to be sent in the ISO-639-1 standard.
last_name (string) User’s Last Name
marked_email_as_spam_at (string) Date at which the user’s email was marked as spam. Must be in ISO 8601 format or in yyyy-MM-dd’T’HH:mm:ss.SSSZ format.
phone (string) Phone number
push_subscribe (string) Available values are “opted_in” (explicitly registered to receive push messages), “unsubscribed” (explicitly opted out of push messages), and “subscribed” (neither opted in nor out).
push_tokens Array of objects with app_id and token string. You may optionally provide a device_id for the device this token is associated with, e.g., [{“app_id”: App Identifier, “token”: “abcd”, “device_id”: “optional_field_value”}]. If a device_id is not provided, one will be randomly generated.
time_zone (string) Time Zone’s must be sent as per IANA Time Zone Database (e.g., “America/New_York” or “Eastern Time (US & Canada)”). Only valid values will be respected
twitter_id Twitter ID

updateUserProfile

To update user profile attributes which are already set, use the following api.

Note : Do not call this api before calling setUserProfile.

//Create Pyze Profile Attributes object
var pyzeProfileAttributes = {
   "email_id"        : "xyz2@abc.com",
   "date_of_birth"   : "1984-07-01",
   "first_name"      : "John M",
   "last_name"       : "Jacobs"
}
//Create Custom Profile Attributes object
var customProfileAttributes = {
   "age"       : 29,
   "pincode"   : "232001",
   "city"      : "XYZ2"
}
//Call the updateUserProfileAttributes API
PyzeIdentity.updateUserProfile(pyzeProfileAttributes,customProfileAttributes);

resetUserProfile

This API is used to reset the user. Call this when you want to remove user from the device.

PyzeIdentity.resetUserProfile();

5. User Privacy

Pyze provides APIs to allow end-users to Opt out of Data Collection and instruct the Pyze system to forget a user’s data.

1. Adding User Privacy

setUserOptOut

Allows end-users to opt out from data collection. Opt-out can be toggled true or false.

Pyze.setUserOptOut(true) 

To resume user data collection set value to false

Pyze.setUserOptOut(false) 

deleteUser

Allows end-users to opt out from data collection and delete the user in the Pyze system. We recommend you confirm this action as once a user is deleted, this cannot be undone.

Pyze.deleteUser(true)