Conditionally Initializing Pendo

In a basic Pendo installation, you would initialize Pendo for all users of your application and then rely on the include and exclude lists to filter out the analytics from specific visitor IDs, account IDs, or domains. This works well to exclude visitors from lower (test/staging) environments or exclude internal users. 

However, sometimes you may want to exclude a group of users but cannot use the visitor ID, account ID, or domain to exclude those users. In that case, you may want to conditionally initialize Pendo. 

 

Example

In the AcmeCorp CRM app visitors can either be part of a free plan or a paid plan. In this example we only want Pendo initialized for visitors on the paid plan. Because the free visitors belong to multiple accounts and all are active on our primary (production) domain we cannot use an exclude list to exclude their activity. 

In this case, we would want to conditionally initialize Pendo so that it is only running when paid users sign in. To do this you will want to update your Pendo snippet to wrap it in some conditional logic to decide when Pendo should and should not initialize.

The pseudocode below illustrates how you would accomplish this: 

if (user.type=='paid') {
 pendo.initialize()...
else {
}

 

In this example, we have a user with a trait of 'type' that can either be 'free' or 'paid'. We are wrapping the Pendo initialization code in an if/else statement to check the 'type' trait of the visitor and only initialize Pendo if that is equal to 'paid'. This allows you to exclude all 'free' users from Pendo while continuing to use Pendo for all 'paid' users.