Targeting
Replace Study targeting
Atomically replaces every Event trigger, audience condition, and display delay for an editable IN_PRODUCT_SURVEY Study.
PUT
/
v2
/
studies
/
{studyId}
/
targeting
Replace Study targeting
curl --request PUT \
--url https://api.sprig.com/v2/studies/{studyId}/targeting \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--header 'If-Match: <if-match>' \
--data '
{
"triggers": [
{
"id": "11111111-1111-4111-8111-111111111111"
}
],
"audience": {
"operator": "AND",
"conditions": [
{
"type": "ATTRIBUTE",
"attribute": "plan",
"comparator": "EQUALS",
"value": "enterprise"
},
{
"type": "PAGE_VIEW_COUNT",
"comparator": "GREATER_THAN_OR_EQUAL",
"value": 3
}
]
},
"delaySeconds": 10
}
'import requests
url = "https://api.sprig.com/v2/studies/{studyId}/targeting"
payload = {
"triggers": [{ "id": "11111111-1111-4111-8111-111111111111" }],
"audience": {
"operator": "AND",
"conditions": [
{
"type": "ATTRIBUTE",
"attribute": "plan",
"comparator": "EQUALS",
"value": "enterprise"
},
{
"type": "PAGE_VIEW_COUNT",
"comparator": "GREATER_THAN_OR_EQUAL",
"value": 3
}
]
},
"delaySeconds": 10
}
headers = {
"If-Match": "<if-match>",
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {
'If-Match': '<if-match>',
Authorization: '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
triggers: [{id: '11111111-1111-4111-8111-111111111111'}],
audience: {
operator: 'AND',
conditions: [
{
type: 'ATTRIBUTE',
attribute: 'plan',
comparator: 'EQUALS',
value: 'enterprise'
},
{type: 'PAGE_VIEW_COUNT', comparator: 'GREATER_THAN_OR_EQUAL', value: 3}
]
},
delaySeconds: 10
})
};
fetch('https://api.sprig.com/v2/studies/{studyId}/targeting', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sprig.com/v2/studies/{studyId}/targeting",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'triggers' => [
[
'id' => '11111111-1111-4111-8111-111111111111'
]
],
'audience' => [
'operator' => 'AND',
'conditions' => [
[
'type' => 'ATTRIBUTE',
'attribute' => 'plan',
'comparator' => 'EQUALS',
'value' => 'enterprise'
],
[
'type' => 'PAGE_VIEW_COUNT',
'comparator' => 'GREATER_THAN_OR_EQUAL',
'value' => 3
]
]
],
'delaySeconds' => 10
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json",
"If-Match: <if-match>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.sprig.com/v2/studies/{studyId}/targeting"
payload := strings.NewReader("{\n \"triggers\": [\n {\n \"id\": \"11111111-1111-4111-8111-111111111111\"\n }\n ],\n \"audience\": {\n \"operator\": \"AND\",\n \"conditions\": [\n {\n \"type\": \"ATTRIBUTE\",\n \"attribute\": \"plan\",\n \"comparator\": \"EQUALS\",\n \"value\": \"enterprise\"\n },\n {\n \"type\": \"PAGE_VIEW_COUNT\",\n \"comparator\": \"GREATER_THAN_OR_EQUAL\",\n \"value\": 3\n }\n ]\n },\n \"delaySeconds\": 10\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("If-Match", "<if-match>")
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://api.sprig.com/v2/studies/{studyId}/targeting")
.header("If-Match", "<if-match>")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"triggers\": [\n {\n \"id\": \"11111111-1111-4111-8111-111111111111\"\n }\n ],\n \"audience\": {\n \"operator\": \"AND\",\n \"conditions\": [\n {\n \"type\": \"ATTRIBUTE\",\n \"attribute\": \"plan\",\n \"comparator\": \"EQUALS\",\n \"value\": \"enterprise\"\n },\n {\n \"type\": \"PAGE_VIEW_COUNT\",\n \"comparator\": \"GREATER_THAN_OR_EQUAL\",\n \"value\": 3\n }\n ]\n },\n \"delaySeconds\": 10\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sprig.com/v2/studies/{studyId}/targeting")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["If-Match"] = '<if-match>'
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"triggers\": [\n {\n \"id\": \"11111111-1111-4111-8111-111111111111\"\n }\n ],\n \"audience\": {\n \"operator\": \"AND\",\n \"conditions\": [\n {\n \"type\": \"ATTRIBUTE\",\n \"attribute\": \"plan\",\n \"comparator\": \"EQUALS\",\n \"value\": \"enterprise\"\n },\n {\n \"type\": \"PAGE_VIEW_COUNT\",\n \"comparator\": \"GREATER_THAN_OR_EQUAL\",\n \"value\": 3\n }\n ]\n },\n \"delaySeconds\": 10\n}"
response = http.request(request)
puts response.read_body{
"code": "<string>",
"message": "<string>",
"errors": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>",
"resource": {
"type": "<string>",
"id": "<string>"
}
}
]
}{
"code": "<string>",
"message": "<string>",
"errors": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>",
"resource": {
"type": "<string>",
"id": "<string>"
}
}
]
}{
"code": "<string>",
"message": "<string>",
"errors": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>",
"resource": {
"type": "<string>",
"id": "<string>"
}
}
]
}{
"code": "<string>",
"message": "<string>",
"errors": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>",
"resource": {
"type": "<string>",
"id": "<string>"
}
}
]
}{
"code": "<string>",
"message": "<string>",
"errors": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>",
"resource": {
"type": "<string>",
"id": "<string>"
}
}
]
}{
"code": "<string>",
"message": "<string>",
"errors": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>",
"resource": {
"type": "<string>",
"id": "<string>"
}
}
]
}Authorizations
Use API-Key YOUR_API_KEY. The key selects the Production or Development environment.
Headers
Quoted Study version last read from ETag or Study.version. Required on mutating Study writes.
Example:
"\"126300\""
Path Parameters
Body
application/json
The complete targeting sub-resource for an IN_PRODUCT_SURVEY Study.
One to 10 existing Events. A matching Event triggers the Study, so multiple entries use OR semantics.
Required array length:
1 - 10 elementsShow child attributes
Show child attributes
Audience rules, or null to target every visitor.
- Attribute comparison
- Attribute text match
- Attribute presence
- Identified visitor
- Language
- Device type
- Group membership
- Session count
- Page view count
- Condition group
Show child attributes
Show child attributes
Seconds to wait after the trigger before showing the Study. Use 0 for no delay.
Required range:
0 <= x <= 999Response
No Content
Was this page helpful?
⌘I
Replace Study targeting
curl --request PUT \
--url https://api.sprig.com/v2/studies/{studyId}/targeting \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--header 'If-Match: <if-match>' \
--data '
{
"triggers": [
{
"id": "11111111-1111-4111-8111-111111111111"
}
],
"audience": {
"operator": "AND",
"conditions": [
{
"type": "ATTRIBUTE",
"attribute": "plan",
"comparator": "EQUALS",
"value": "enterprise"
},
{
"type": "PAGE_VIEW_COUNT",
"comparator": "GREATER_THAN_OR_EQUAL",
"value": 3
}
]
},
"delaySeconds": 10
}
'import requests
url = "https://api.sprig.com/v2/studies/{studyId}/targeting"
payload = {
"triggers": [{ "id": "11111111-1111-4111-8111-111111111111" }],
"audience": {
"operator": "AND",
"conditions": [
{
"type": "ATTRIBUTE",
"attribute": "plan",
"comparator": "EQUALS",
"value": "enterprise"
},
{
"type": "PAGE_VIEW_COUNT",
"comparator": "GREATER_THAN_OR_EQUAL",
"value": 3
}
]
},
"delaySeconds": 10
}
headers = {
"If-Match": "<if-match>",
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {
'If-Match': '<if-match>',
Authorization: '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
triggers: [{id: '11111111-1111-4111-8111-111111111111'}],
audience: {
operator: 'AND',
conditions: [
{
type: 'ATTRIBUTE',
attribute: 'plan',
comparator: 'EQUALS',
value: 'enterprise'
},
{type: 'PAGE_VIEW_COUNT', comparator: 'GREATER_THAN_OR_EQUAL', value: 3}
]
},
delaySeconds: 10
})
};
fetch('https://api.sprig.com/v2/studies/{studyId}/targeting', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sprig.com/v2/studies/{studyId}/targeting",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'triggers' => [
[
'id' => '11111111-1111-4111-8111-111111111111'
]
],
'audience' => [
'operator' => 'AND',
'conditions' => [
[
'type' => 'ATTRIBUTE',
'attribute' => 'plan',
'comparator' => 'EQUALS',
'value' => 'enterprise'
],
[
'type' => 'PAGE_VIEW_COUNT',
'comparator' => 'GREATER_THAN_OR_EQUAL',
'value' => 3
]
]
],
'delaySeconds' => 10
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json",
"If-Match: <if-match>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.sprig.com/v2/studies/{studyId}/targeting"
payload := strings.NewReader("{\n \"triggers\": [\n {\n \"id\": \"11111111-1111-4111-8111-111111111111\"\n }\n ],\n \"audience\": {\n \"operator\": \"AND\",\n \"conditions\": [\n {\n \"type\": \"ATTRIBUTE\",\n \"attribute\": \"plan\",\n \"comparator\": \"EQUALS\",\n \"value\": \"enterprise\"\n },\n {\n \"type\": \"PAGE_VIEW_COUNT\",\n \"comparator\": \"GREATER_THAN_OR_EQUAL\",\n \"value\": 3\n }\n ]\n },\n \"delaySeconds\": 10\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("If-Match", "<if-match>")
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://api.sprig.com/v2/studies/{studyId}/targeting")
.header("If-Match", "<if-match>")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"triggers\": [\n {\n \"id\": \"11111111-1111-4111-8111-111111111111\"\n }\n ],\n \"audience\": {\n \"operator\": \"AND\",\n \"conditions\": [\n {\n \"type\": \"ATTRIBUTE\",\n \"attribute\": \"plan\",\n \"comparator\": \"EQUALS\",\n \"value\": \"enterprise\"\n },\n {\n \"type\": \"PAGE_VIEW_COUNT\",\n \"comparator\": \"GREATER_THAN_OR_EQUAL\",\n \"value\": 3\n }\n ]\n },\n \"delaySeconds\": 10\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sprig.com/v2/studies/{studyId}/targeting")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["If-Match"] = '<if-match>'
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"triggers\": [\n {\n \"id\": \"11111111-1111-4111-8111-111111111111\"\n }\n ],\n \"audience\": {\n \"operator\": \"AND\",\n \"conditions\": [\n {\n \"type\": \"ATTRIBUTE\",\n \"attribute\": \"plan\",\n \"comparator\": \"EQUALS\",\n \"value\": \"enterprise\"\n },\n {\n \"type\": \"PAGE_VIEW_COUNT\",\n \"comparator\": \"GREATER_THAN_OR_EQUAL\",\n \"value\": 3\n }\n ]\n },\n \"delaySeconds\": 10\n}"
response = http.request(request)
puts response.read_body{
"code": "<string>",
"message": "<string>",
"errors": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>",
"resource": {
"type": "<string>",
"id": "<string>"
}
}
]
}{
"code": "<string>",
"message": "<string>",
"errors": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>",
"resource": {
"type": "<string>",
"id": "<string>"
}
}
]
}{
"code": "<string>",
"message": "<string>",
"errors": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>",
"resource": {
"type": "<string>",
"id": "<string>"
}
}
]
}{
"code": "<string>",
"message": "<string>",
"errors": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>",
"resource": {
"type": "<string>",
"id": "<string>"
}
}
]
}{
"code": "<string>",
"message": "<string>",
"errors": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>",
"resource": {
"type": "<string>",
"id": "<string>"
}
}
]
}{
"code": "<string>",
"message": "<string>",
"errors": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>",
"resource": {
"type": "<string>",
"id": "<string>"
}
}
]
}