Key-value pair targeting

Your account will require:

  • Admin access or Domain access to property

  • Feature access to message/scenario partition set management

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.

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 passing the key-value pair of dark-mode: true for all campaigns run on the property using the targetingParams parameter to identify users who have dark mode enabled on their web browser. In the configure key-value pair in scenario step, the true value will be used to drive a unique messaging experience for dark-mode users.

Code example
Code example
window._sp_queue = [];window._sp_ = {
config: {
accountId: 1111,
baseEndpoint: 'https://cdn.privacy-mgmt.com',
ccpa: {
targetingParams:{
darkmode: false
}
},
gdpr: { },
propertyHref: 'https://www.testdemo.com',
campaignEnv: 'stage',
isSPA: true
targetingParams:{
darkmode: true
}
}
}

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 a unique messaging experience for dark-mode users when the true value is passed.

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

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

In this example, your organization would like to display a first layer message for webpages that includes a key dark-mode with a value of true.

  1. In the following Key Value Pair Targeting panel, toggle the Pages button to Include.

  2. Set the 'Key' to the value 'dark-mode'

  3. Your organization wants to display when the key matches the value 'true'. Therefore select the 'Value' setting to 'match'

  4. Set the 'String' value to 'true'

  5. Click 'Add' to save this setup

Click 'Save' (or 'Update') to save the scenario:

Failure to click 'Save' or 'Update' will result in all changes being lost.

In this example, when a key-value pair dark-mode: true is delivered through the targetingParams implemented on a webpage the dark-mode message experience will be delivered.