Campaigns NQL examples

Refer to the Launching campaign programs documentation for guidelines on planning, gaining approval, testing and launching your campaign within your organization.

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

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

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 Schedule trigger method on the General tab.

  • Select Again after from the Target employees will receive the campaign section and provide the minimum number of days you want between responses for each employee.

  • Save the campaign at least once before using the NQL query below. This ensures the system recognizes your campaign and avoids a Table does not exist error during NQL query validation.

Example queries to inspect campaign results

All responses

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

Summary view

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.

Count responses per state

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

Count responses for a specific user

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

Historical states

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

Count the number of answered or declined responses

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

Count the number of responses by question choice

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

List users who answered a specific campaign

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

List users who answered with a specific choice

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.

List users with their last answer to a sentiment campaign

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).

List of users with their last answer to a parametric campaign where the parameter had a specific value

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?