Campaigns NQL examples

This list of NQL query examples is designed to help you select the users relevant to your campaign. Go through the queries below, copy the query that is most similar to your use case, and adjust it accordingly.

Example queries to target users in scheduled campaigns

chevron-rightRetrieve all users from a specific city.hashtag
users
| where ad.city == "Lausanne"
chevron-rightRetrieve users with installed Collector (xTray) that has been running on their device in the last 24 hours.hashtag
users
| include execution.events during past 24h
| where binary.name == "nxtray*"
| compute c1 = binary.name.count()
| where c1 > 0
chevron-rightRetrieve users who have installed MS Teams or Zoom in the last day.hashtag
users
| with package.installations during past 1d
| where package.name in [ "MS Teams", "Zoom" ]
chevron-rightRetrieve users from a specific department.hashtag
users
| where ad.department == "Finance"
chevron-rightRetrieve the last user of a device that has had 3 system crashes in the past 7 days.hashtag
devices past 7d
| with device_performance.system_crashes past 7d
| compute nb_crashes = count()
| where nb_crashes >= 3
| with session.events past 7d
| compute user_sid = user.sid.last()
| list user_sid
chevron-rightRetrieve last users not from the IT department who has a poor battery health.hashtag
chevron-rightSchedule a DEX campaignhashtag

To randomly select a different sample of employees to continuously collect the sentiment data, set up the query Below. Replace #dex_campaign_name with the NQL ID of the campaign and adjust the limit below set as 50 to specify the number of new users the campaign targets every hour.

Note that you need to:

  • Define the trigger Schedule and select Only after the (minimum) number of days you want to have in between responses for each employee

  • First, save the campaign at least once before you can use the below NQL query, so that the system is aware that your campaign exists and does not generate a "Table does not exist" error when validating the NQL query.

Example queries to inspect campaign results

chevron-rightAll responseshashtag

All responses for the Remote Work Demo campaign, displaying the username, time, state and state_details, all per user.

chevron-rightSummary viewhashtag

Summary view of the Remote Work Demo campaign responses in terms of campaign trigger_method, time, state, state_details and the number of questions answered, all per user.

chevron-rightCount responses per statehashtag

Count campaign responses for the Remote Work Demo campaign by user, state and state_details.

chevron-rightCount responses for a specific userhashtag

Count campaign responses for a specific user by campaign, state and state_details.

chevron-rightHistorical stateshashtag

View the historical states of the campaign responses for the Remote Work Demo campaign.

chevron-rightCount the number of answered or declined responseshashtag

Count the number of answered or declined responses of a campaign with the #my_campaign NQL ID.

chevron-rightCount the number of responses by question choicehashtag

Count the number of responses by question choice for a single-choice, opinion-scale or NPS question with the vpn_quality question ID.

chevron-rightList users who answered a specific campaignhashtag

List the users who answered a campaign with the #my_campaign NQL ID.

chevron-rightList users who answered with a specific choicehashtag

List users who answered with the choice labeled as always for the question with the how_often NQL ID for the campaign with the #my_campaign NQL ID.

chevron-rightList users with their last answer to a sentiment campaignhashtag

List all users with their last answers to the question with the sentiment question ID for the sentiment campaign with the #service_sentiment NQL ID (if any).

chevron-rightList of users with their last answer to a parametric campaign where the parameter had a specific valuehashtag

List users with their last answer and comment to the question with the sentiment question ID and the ticket_number parameter associated with the request for the parametric campaign with the #ticket_satisfaction NQL ID, where the parameter value with the issue_type ID is Incident.

Last updated

Was this helpful?