Permission: Campaign entities

Key-value pairs allow your organization to add customized targeting in your scenarios based on values you define and pass into the Sourcepoint platform. Using these values, your organization can then build messaging logic to serve different experiences to the end-user.

In this article, we will cover the two corresponding configurations needed to successfully utilize key-value pairing in your scenarios.

Insert targetingParams parameter into implementation code

Key-value pairs must first be added to the on-page client configuration code snippet using the targetingParams parameter. Multiple key-value pairs can be added per messaging call.

  Note: targetingParams can be added to the overall implementation code and/or per messaging campaign type in the implementation code. Please review our implementation documentation for more information.

targetingParams set at the campaign type will override targetingParams set at the overall implementation code for that specific campaign type.

In the example below, we are checking if the end-user has enabled a "dark theme" for their browser and then assigning this boolean variable to the darkMode key. This key-value pair will be used to drive a unique messaging experience for dark-mode users.

// Checking for dark theme
const browserTheme = window.matchMedia('(prefers-color-scheme: dark)').matches;

window._sp_queue = [];window._sp_ = {    
    config: {        
                accountId: 1111,        
                baseEndpoint: '',        
                ccpa: { },        
                gdpr: { },        
                propertyHref: '',        
                campaignEnv: 'stage',        
                isSPA: true,
                // passing boolean value and assigning it to darkMode key-value pair
                            darkMode: browserTheme          

The value set can be a string, boolean or integer value. JavaScript variables that evaluate to either strings, boolean values or integers can be passed.

Configure key-value pair in scenario

To leverage the data being passed into the Sourcepoint platform, your organization will need to build out the messaging logic in the scenario builder based on the passed values.

As indicated above, our goal in this example is to deliver two different messaging experiences - one for browsers who use a dark theme and one for browsers who do not use a dark theme (i.e. a unique messaging experience for when darkMode is paired with true and a unique messaging experience when darkMode is paired with false.

From a new or existing step in a scenario, click Add condition.


Select Key Value Pair Targeting in the subsequent Conditions dropdown list.


Use the subsequent key-value statement builder to configure the targeting for the condition. 

  Note: Click the + symbol to add multiple key-value statements to a single condition. Multiple key-value statements within a single condition will utilize AND logic to satisfy the condition. That is, all statements must be met before the condition is be satisfied.



In this example, your organization would like to display a unique first layer message when an end-user's browsers is using a dark theme (e.g. darkMode:true).

  1. In the following Key Value Pair Targeting panel, ensure that the Pages toggle is set to Include
  2. Set the Key field to darkMode.
  3. Set the Value field to match 
  4. Input true into the String field. 
  5. Click Add to save this setup.
  6. Configure the message that should be displayed with this key-value condition and all other conditions in the step are satisfied.


Repeat as necessary for when your key is paired with a false value (e.g. darkMode:false).

Click Save (or Update) to save the scenario: 


Pass targetingParams via query string

The key-value pairs configured in your scenario can be passed via query string to drive the messaging logic configured in your scenario. Follow the template below for your query string to pass your targetingParams:



Was this article helpful?
0 out of 1 found this helpful



Article is closed for comments.