Zudy Vinyl
Before starting your application instrumentation, ensure that you have created an app and have an appKey
Install
Installing Pyze Analytics for Vinyl is simple, and requires adding the Pyze Javascript as a site widget in the Vinyl IDE
Create a new site widget, and paste the below script within binder.js as shown:
define(function () {
const install = function (context) {
var pyzeAppKey= context.getParameter('AppKey');
!function(e,t){var s=e.Pyze||{_q:[]},i=e.PyzeEvents||{_q:[]},n=e.PyzeCuratedEvents||{_q:[]},r=e.PyzeIdentity||{_q:[]};function p(t,e){function s(e){t[e]=function(){t._q.push([e].concat(Array.prototype.slice.call(arguments,0)))}}for(var i=0;i<e.length;i++)s(e[i])}p(s,["initialize","getTimerReference","getAppInstanceId","postWebAppVersion","postPageView","setUserOptOut","deleteUser"]),p(i,["postCustomEvent","startTimerForEvent","postCustomEventWithAttributes","postTimedEvent","postTimedEventWithAttributes","postExplicitActivation"]),p(n,["post"]),p(r,["setUserProfile","resetUserProfile","updateUserProfile"]);var o=t.createElement("script"),a=t.getElementsByTagName("script")[0];o.type="text/javascript",o.async=!0,o.src="https://cdn.pyze.com/pyze.js",a.parentNode.insertBefore(o,a),e.Pyze=s,e.PyzeEvents=i,e.PyzeCuratedEvents=n,e.PyzeIdentity=r}(window,document),Pyze.initialize(pyzeAppKey);
console.log(pyzeAppKey);
}
return {
callbacks: {
install: install
}
};
});
Initialize
To initialize the Pyze SDK, add the site widget you created to your environment via the Control Panel:
Warning
Make sure you replacedYOUR_PYZE_APP_KEY
with your own appKey
The Pyze SDK will now start capturing many automated metrics.
Custom Events
Events allow you to easily track unique user actions within your app.
Setup
- Create a new Connection, of type
Rest API
- Set the base url to
https://import.pyze.com
- Create a
POST
endpoint forv1/events
- Add the following parameters:
appKey
,event
,eventTime
,type
,userId
Event
Pyze custom events can be called from XP CRUD
rules within your application.
Create a new XP Crud
Rule, that will send your Custom Event from your Application to the Pyze Rest API created above.
- Set the
event
Column to the name of the event - Set the
eventTime
Column toNOW()
- Set the
userID
Column toWHO()
This allows you to track when a user executed an action, for a simple count of how often that event is occurring.
Event with Attributes
Attributes are any key-value pair that you can attach to an event. You can have up to 99 attributes with any event. It is highly recommended to follow our Best Practices and heavily rely on attributes to make your instrumentation as minimal and useful as possible. In a typical application, you should have many more attributes than events.
- Pyze API to send custom attributes accepts the attributes in JSON format.
- Create a new
XP_CRUD
rule in your application as above - Add an
attributes
Column with any JSON values from your application such as:
'{
"TicketID": "' || CAST(TS.TicketID as NVARCHAR(64)) || '",
"Assigned User Id":"' || CAST(TS.AssignedUserID as NVARCHAR(64)) || '" ,
"Priority Id":"' || CAST(TS.TicketPriorityID as NVARCHAR(64)) || '",
"Company Id":"' || CAST(TS.CompanyID as NVARCHAR(64)) || '",
"ApplicationName": "Ticketing"
}'
Profile
Profiles are a powerful way to add data about your users to Pyze. Use profiles to add data that is not specific to a point in time (events) and are attached to a specific user.
When a user logs in to your app, call setUserProfile
to identify them to Pyze. Any events that happen after they are identified, will be attributed to this user. You should only call this method once upon the initial login of a session.
You can optionally include profile attributes.
Pyze built-in profile attributes get special handling in the pyze UI, and we will attempt to discern the data type for custom attributes based on the data recieved. There is no difference between the built-in attributes and custom ones outside of formatting applied.
You can modify your binder.js
in the Site Widget created as part of the installation process to add these profile calls.
//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(context.getCurrentAuthenticationUserName(),pyzeProfileAttributes,customProfileAttributes);
Pyze 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 |
API Reference
Full API reference available here