### Running the example Source: https://support.gainsight.com/PX/Integrations/01Technology_Partner_Integrations/Electron_Desktop_Application Install dependencies and start the application. ```bash # Install the dependencies and run $ npm install && npm start ``` -------------------------------- ### Running Electron Hello World Example Source: https://support.gainsight.com/PX/Integrations/01Technology_Partner_Integrations/Electron_Desktop_Application Clone the Quick Start repository, navigate into it, and install electron-cookies. ```bash # Clone the Quick Start repository $ git clone https://github.com/electron/electron-quick-start # Go into the repository $ cd electron-quick-start # Install electron-cookies $ npm install @exponent/electron-cookies --save ``` -------------------------------- ### CompletionCallback Example Source: https://support.gainsight.com/PX/Mobile/01Getting_Started/Install_Gainsight_PX/Install_Gainsight_PX_MAUI This example demonstrates how to handle errors when creating events using the completion callback. ```csharp Gainsight.CustomEvent(eventName: <#string#>, properties:<#Dictionary#>, (functionName, properties, error) => { if (error != null) { //Success } else { //Failure } }); ``` -------------------------------- ### GET Request Example Source: https://support.gainsight.com/PX/Security_and_Compliance/Enablement/User_Preferences_for_Tracking_and_Engagement Example of a GET request using curl. ```bash curl --request GET 'http://api.aptrinsic.com/v1/user/preferences/johndoe@example.com' \ --header 'X-APTRINSIC-API-KEY: aa8893cd-5cf8-493d-1780-fa199f19f005' ``` -------------------------------- ### Exception Handling Example Source: https://support.gainsight.com/PX/Install_PX/Install_PX_Mobile/Install_Gainsight_PX_Flutter Example of how to handle exceptions when creating events, checking for PlatformException. ```dart GainsightPX.instance.customEvent(eventName, properties) .then((value) => { if (value is PlatformException) { // on Failure ... } else { // on Success ... } }); ``` -------------------------------- ### Configuration Example with Disk Queue Source: https://support.gainsight.com/PX/API_for_Developers/SDKs/Gainsight_PX_C_SDK This example shows how to configure the SDK to use a disk queue for caching events, including setting a directory and queue limit. ```csharp Config config = new Config.Builder() { DurableQueueDirectoryName = "C:\GPX", DurableQueueEncryption = null, // add your own IStorageEncryption implementation if needed QueueLimit = 1000 }.Build(); ``` -------------------------------- ### Engagement Navigation Event Example Source: https://support.gainsight.com/PX/API_for_Developers/02Usage_of_Different_APIs/Javascript_Event_Listener_API Example of an Engagement Navigation event payload. Possible values for actionType: Next Step, Skip, Previous Step, Go to Step, Start Over, End Guide. ```javascript "", { "engagementId":"f6bfbe59-643c-4b66-a6c8-30af8d8c5ab6", "executionId":"13c42c83-5930-437e-bf4f-854f47f5979c", "executionTimestamp":1620838876611, "engagementType":"Guide", "activation":"Auto", "engagementName":"Demo JS Listener ", "customButtonId":"3d399fc8-c412-45b7-a7a5-88955d1fff3f", "interaction":"Engagement Navigation", "actionType": "Next Step", "identifyId":"LNZUgb555555y5EXrAAQzbVJ3" }, { "stepId": "f6bfbe59-643c-4b66-a6c8-30af8d8c5ab6", "stepName": "Demo Slider Step", } ``` -------------------------------- ### GET Response Example Source: https://support.gainsight.com/PX/Security_and_Compliance/Enablement/User_Preferences_for_Tracking_and_Engagement Example of a GET request response. ```json Status: 200 OK { "trackUsage": true, "productUpdates": false, "guidedTours": true, "surveys": null, "onboardingBot": null, "trackEmailAnalytics": false, } ``` -------------------------------- ### Implementing SRI Source: https://support.gainsight.com/PX/Security_and_Compliance/Enablement/Hosting_SDK Example of how to implement the SRI attribute with the PX SDK. ```html ``` -------------------------------- ### Tag Setup Source: https://support.gainsight.com/PX/API_for_Developers/01About/Work_with_Gainsight_PX_Web_SDK This is a sample Tag that needs to be installed on your application so that the events from your web site or web application can be sent to Gainsight PX. Note that the PRODUCT-KEY should come from your Gainsight PX subscription in the Administration > Products. There is a unique PRODUCT-KEY for each Product/Channel combination. ```javascript ``` -------------------------------- ### Example of hosting a specific SDK version Source: https://support.gainsight.com/PX/Security_and_Compliance/Enablement/Hosting_SDK This snippet shows how to include a specific version of the SDK in your HTML using a script tag. ```html ``` -------------------------------- ### ExceptionCallback Example Source: https://support.gainsight.com/PX/Mobile/01Getting_Started/Install_Gainsight_PX/07_Install_Gainsight_PX_Xamarin This example demonstrates how to handle errors when creating events using the error callback. ```csharp Gainsight.CustomEvent(eventName: <#string#>, properties:<#Dictionary#>, (functionName, properties, error) => { if (error != null) { //Success } else { //Failure } }); ``` -------------------------------- ### Configure the tag with Security Filters Example Source: https://support.gainsight.com/PX/API_for_Developers/01About/Security_Tracking_Filters Example demonstrating how to create a configuration object with URL and query parameter filters and pass it to the Gainsight PX tag. ```javascript // ---- create the relevant config: ---- //var config = { // url filters example filterUrls : ["*app2/index1.html*", "*app2/buttons.html*"], // list of URLs to filter or exclude filterType : "mask", // "exclude" OR "mask" // query parameter filters example namedParamFilter : ["internalID"], nameParamFilterType : "exclude" // "exclude" OR "mask"}; // ---- pass the config to the tag: ---- (function(n,t,a,e,x) { var i="aptrinsic";n[i]=n[i]||function() { (n[i].q=n[i].q||[]).push(arguments)} ,n[i].p=e;n[i].c=x; var r=t.createElement("script");r.async=!0,r.src=a+"?a="+e; var c=t.getElementsByTagName("script")[0]; c.parentNode.insertBefore(r,c)}) (window,document,"https://web-sdk.aptrinsic.com/api/aptrinsic.js", "AP-USE-YOU-REAL-TAG-PLEASE-DO-NOT-COPY-PASTE-2", config); } ``` -------------------------------- ### Engagement Callback Example Source: https://support.gainsight.com/PX/Install_PX/Install_PX_Mobile/Install_Gainsight_PX_NativeScript Example of implementing the EngagementCallback class for mobile engagements in Gainsight PX. ```typescript import {EngagementCallback, EngagementMetaData, JsonMap} from "../../../src/gainsight-px-bridge.common"; import { Toast } from "~/utils/Toast"; export class GlobalEngagementCallback extends EngagementCallback { constructor() { super(); } onCallback(engagementMetaData: EngagementMetaData) { super.onCallback(engagementMetaData); if (engagementMetaData.actionType === "link") { let text = "EngagementMetaData:" + ", actionText: " + engagementMetaData.actionText + ", actionType: " + engagementMetaData.actionType + ", engagementId: " + engagementMetaData.engagementId + ", engagementName: " + engagementMetaData.engagementName + ", scope: " + engagementMetaData.scope.toString() Toast.showText(text); } } } let configs: GainsightPXConfiguration = { apiKey: <##API_KEY##>, shouldTrackTapEvents: true, enableLogs: true, reportTrackingIssues: true, engagementCallback: new GlobalEngagementCallback() }; Gainsight.initialize(configs) .catch((error: GainsightPXCallback) => { console.log('initialize exceptionMessage: ' + error.exceptionMessage) }); ``` -------------------------------- ### Tag Snippet Example Source: https://support.gainsight.com/PX/Security_and_Compliance/Enablement/Hosting_SDK This is an example of the snippet when using the most latest SDK version. ```javascript ``` -------------------------------- ### Engagement Callback Example Source: https://support.gainsight.com/PX/Mobile/01Getting_Started/Install_Gainsight_PX/05_Install_Gainsight_PX_NativeScript?mt-draft=true Example of implementing and configuring the Engagement Callback feature for Gainsight PX in a NativeScript application. ```typescript import {EngagementCallback, EngagementMetaData, JsonMap} from "../../../src/gainsight-px-bridge.common"; import { Toast } from "~/utils/Toast"; export class GlobalEngagementCallback extends EngagementCallback { constructor() { super(); } onCallback(engagementMetaData: EngagementMetaData) { super.onCallback(engagementMetaData); if (engagementMetaData.actionType === "link") { let text = "EngagementMetaData:" + ", actionText: " + engagementMetaData.actionText + ", actionType: " + engagementMetaData.actionType + ", engagementId: " + engagementMetaData.engagementId + ", engagementName: " + engagementMetaData.engagementName + ", scope: " + engagementMetaData.scope.toString() Toast.showText(text); } } } let configs: GainsightPXConfiguration = { apiKey: <##API_KEY##>, shouldTrackTapEvents: true, enableLogs: true, reportTrackingIssues: true, engagementCallback: new GlobalEngagementCallback() }; Gainsight.initialize(configs) .catch((error: GainsightPXCallback) => { console.log('initialize exceptionMessage: ' + error.exceptionMessage) }); ``` -------------------------------- ### General Methods Source: https://support.gainsight.com/PX/Install_PX/Install_PX_Mobile/Install_Gainsight_PX_SDK_for_Android Examples of general methods for Gainsight PX SDK including flush, reset, shutdown, enable, and check enabled status. ```java GainsightPX.with().flush(); ``` ```java GainsightPX.with().reset(); ``` ```java GainsightPX.with().shutdown() ``` ```java GainsightPX.with().enableEngagements(boolean enable) ``` ```java boolean enabled = GainsightPX.with().enabled(); ``` -------------------------------- ### General Method - Enable Source: https://support.gainsight.com/PX/Install_PX/Install_PX_Mobile/Install_Gainsight_PX_SDK_for_iOS Enables the Gainsight PX instance to collect and send events. ```swift **GainsightPX**.shared.engagements(enable: Bool) ``` -------------------------------- ### Example of Adding Exception Handler Source: https://support.gainsight.com/PX/Install_PX/Install_PX_Mobile/Install_Gainsight_PX_SDK_for_Android This example demonstrates how to attach the custom GlobalExceptionHandler to the identify method in Gainsight PX. ```java GainsightPX.with().identify(@NonNull String userId, GlobalExceptionHandler.instance(context)); ``` -------------------------------- ### Identify Call Example Source: https://support.gainsight.com/PX/Install_PX/Install_PX_Web/Install_Gainsight_PX_on_Your_Web_App Example of the identify() javascript call to pass user and account information to Gainsight PX. ```javascript //passing user and account objects: aptrinsic("identify", { //User Fields "id": "unique-user-id", // Required for logged in app users "email": "userEmail@address.com", "firstName": "John", "lastName": "Smith", "signUpDate": 1522697426479, //unix time in ms "plan" : "gold", //Custom attributes - please create those custom attributes in aptrinsic via Administration to be tracked. "price" : 95.5, "userHash": "" // optional transient for HMAC identification }, { //Account Fields "id":"IBM", //Required "name":"International Business Machine", "Program": "Platinum" // flat custom attributes }); ```