User Segmentation for Salesforce Integration

Reference: What is User Segmentation?

 

PREREQUISITES:

  • The offered solution works for Salesforce Lightning only.
  • To use any unmanaged package with Salesforce Lightning, subdomain must be created. For more details refer to this article.

The crucial information required for segmenting users is retrieving identifiers assigned to each user profile. 

Apty team provides an open-source SFDC Package / Application as an extension to the Salesforce instance. This auxiliary application serves as a building block that fills the gap and returns user profile information for the user who is currently logged into the Salesforce system.

This article gives an overview of how to set up User Segmentation by using Salesforce session variables and consists of 4 steps:

Installing Apty Salesforce Integration Package:

The code of the SFDC application has no capability to violate environment security or potential threats of other kinds, the code provided in the package is open and visible, and can be reviewed and edited if necessary. Once installed on the Client’s Salesforce instance, it provides a capability to add a script that requests and receives the necessary information from Salesforce.

Follow the instructions below for accessing and installing Apty Salesforce Integration Package:

1.  Access the unmanaged Apty Salesforce Integration package by following this link. Unmanaged package is an open source solution, which contains the components that can be previewed / edited / configured by the Client side as necessary.

NOTE: Salesforce packages require My Domain to be set up in your Salesforce Instance.

2.  Provide the credentials to the Salesforce organization in which you want to install the package, and click Log In.

3.  An installation page is displayed as shown on the screen. Choose one of the available options from the grid and click Install. The options are:

  • Install for Admins Only,
  • Install for All Users, and
  • Install for Specific Profiles.

4.  Click Done.

5.  The package is now available on the Salesforce site at Setup > Platform Tools > Apps > Packaging > Installed Packages

Retrieving session variables from Salesforce:

1.  Log into the Apty Assist Admin.

2.  On the left side panel select the application key for Salesforce. In our example the application key has been configured as "SFL". 

3.  In the Salesforce menu click the Gear icon to open the Manage Current Application screen.

4. Following are the fields on the Manage Current Application page > Custom JS tab. In the Custom application level javascript field enter the code provided by the Apty Customer Success team. The purpose of this code snippet is to connect to the Apty Salesforce Integration package in order to access attributes related to the profile of a user currently logged in the system: user id, profile name, department, division, last login. These attributes serve as a reference required for Apty Assist segmentation process.

5.  Click Save to allow Apty Assist run the code once the user is logged in the Salesforce.

var iframe = document.createElement('iframe'); iframe.style.display = "none"; iframe.id = "aptyFrame" 

iframe.src = window.location.protocol + ' //' + window.location.host + '/c/aptySalesforceIntegration.app'; 

if(window==window.top){ document.body.appendChild(iframe); var checkDataExist = setInterval(function() { 

var dataSpan = window.frames['aptyFrame'
        ].contentWindow.document.querySelector('[data-auraclass="uiOutputText"
        ]'); 

if(dataSpan){ 

var data = JSON.parse(dataSpan.innerHTML); if (dataSpan && data) { clearInterval(checkDataExist); console.log('Interval cleared'); 

window.apty_sfdc_user_info = data;
            }
        }
    },
    100);
}

Using Salesforce session variables for Segmentation in Apty Assist:

To use the values obtained from apty_sfdc_user_info variable getting data from Salesforce:

1.  Log into the Apty Assist Admin.

2.  On the left side panel select the application key for Salesforce. In our example the application key has been configured as "SFL".

3.  Click on Manage Application > Segmentation.

4.  At the top right corner of the screen click New Segment.

5.  In the opened window fill out the fields as shown below:

Name:
Provide a unique name of the segment, preferably identifying the criterion by which the end users are to be groped (for example, System Administrators). Once connected to Salesforce, this name is going to be displayed in the Apty Player > Connected Segments section.
Segment Type:
In the drop-down list select “User Variable”.
Variable Name:

Define apty_sfdc_user_info. Profile as the name of the variable.

NOTE: Other variables (department, division, etc.) can be used for segmentations purposes as well.

Variable Value:
Provide the variable value to be used in the system.

4.  At the top of the window switch to the Items tab and select at least one instructional element (Workflow, Validation, Announcement, etc.) to be tied to this Segment. More elements can be added later by accessing this Segment in the Apty Assist Admin.

5.  Click Add to save settings of the new Segment.

6.  To start using the instructional content with regards to the settings of the Segment, make sure to publish it (see the screen below).

Using Salesforce Values for User Tracking 

By default, Apty Assist uses custom user tracking and may be configured to use Salesforce ID for user tracking instead. To achieve that, follow the steps below:

1.  Go to Apty Assist Admin > Salesforce > Manage Current Application (Gear icon) > User Identification

2.  In the Identify users by drop-down list select “Variable”.

3.  Define the variable name in the area below and save the changes made.