curl --request POST \
--url https://{baseurl}/api/v2/client/{workspaceId}/creatives/events \
--header 'Content-Type: text/plain' \
--data '{
"deviceType": "phone",
"events": [
{
"creativeId": "clcr1234567890123456789012",
"type": "impression"
},
{
"creativeId": "clcr1234567890123456789012",
"type": "click"
}
],
"page": "example.com/pricing"
}'import requests
url = "https://{baseurl}/api/v2/client/{workspaceId}/creatives/events"
payload = "{\n \"deviceType\": \"phone\",\n \"events\": [\n {\n \"creativeId\": \"clcr1234567890123456789012\",\n \"type\": \"impression\"\n },\n {\n \"creativeId\": \"clcr1234567890123456789012\",\n \"type\": \"click\"\n }\n ],\n \"page\": \"example.com/pricing\"\n}"
headers = {"Content-Type": "text/plain"}
response = requests.post(url, data=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'text/plain'},
body: '{\n "deviceType": "phone",\n "events": [\n {\n "creativeId": "clcr1234567890123456789012",\n "type": "impression"\n },\n {\n "creativeId": "clcr1234567890123456789012",\n "type": "click"\n }\n ],\n "page": "example.com/pricing"\n}'
};
fetch('https://{baseurl}/api/v2/client/{workspaceId}/creatives/events', 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://{baseurl}/api/v2/client/{workspaceId}/creatives/events",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\n \"deviceType\": \"phone\",\n \"events\": [\n {\n \"creativeId\": \"clcr1234567890123456789012\",\n \"type\": \"impression\"\n },\n {\n \"creativeId\": \"clcr1234567890123456789012\",\n \"type\": \"click\"\n }\n ],\n \"page\": \"example.com/pricing\"\n}",
CURLOPT_HTTPHEADER => [
"Content-Type: text/plain"
],
]);
$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://{baseurl}/api/v2/client/{workspaceId}/creatives/events"
payload := strings.NewReader("{\n \"deviceType\": \"phone\",\n \"events\": [\n {\n \"creativeId\": \"clcr1234567890123456789012\",\n \"type\": \"impression\"\n },\n {\n \"creativeId\": \"clcr1234567890123456789012\",\n \"type\": \"click\"\n }\n ],\n \"page\": \"example.com/pricing\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "text/plain")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{baseurl}/api/v2/client/{workspaceId}/creatives/events")
.header("Content-Type", "text/plain")
.body("{\n \"deviceType\": \"phone\",\n \"events\": [\n {\n \"creativeId\": \"clcr1234567890123456789012\",\n \"type\": \"impression\"\n },\n {\n \"creativeId\": \"clcr1234567890123456789012\",\n \"type\": \"click\"\n }\n ],\n \"page\": \"example.com/pricing\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{baseurl}/api/v2/client/{workspaceId}/creatives/events")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'text/plain'
request.body = "{\n \"deviceType\": \"phone\",\n \"events\": [\n {\n \"creativeId\": \"clcr1234567890123456789012\",\n \"type\": \"impression\"\n },\n {\n \"creativeId\": \"clcr1234567890123456789012\",\n \"type\": \"click\"\n }\n ],\n \"page\": \"example.com/pricing\"\n}"
response = http.request(request)
puts response.read_bodyCount creative events
Counts the Impressions and Clicks of creatives on one page view. The web SDK sends it as text/plain with keepalive, 2 s after the first event of a page or when the page is hidden. An Impression is one page view on which a creative showed; a Click is one press that opened its Destination. The answer is always 204 with no body: requests from bots, over the IP rate limit (600 per minute) or with a body of another shape count nothing, and events for creatives the workspace hasn’t published (or has archived) are dropped. Counts reach GET /api/v3/creatives/{creativeId}/stats within about a minute, through the BullMQ worker. Source of truth for the body: TCreativeEventsBody in packages/creatives/src/events.ts.
curl --request POST \
--url https://{baseurl}/api/v2/client/{workspaceId}/creatives/events \
--header 'Content-Type: text/plain' \
--data '{
"deviceType": "phone",
"events": [
{
"creativeId": "clcr1234567890123456789012",
"type": "impression"
},
{
"creativeId": "clcr1234567890123456789012",
"type": "click"
}
],
"page": "example.com/pricing"
}'import requests
url = "https://{baseurl}/api/v2/client/{workspaceId}/creatives/events"
payload = "{\n \"deviceType\": \"phone\",\n \"events\": [\n {\n \"creativeId\": \"clcr1234567890123456789012\",\n \"type\": \"impression\"\n },\n {\n \"creativeId\": \"clcr1234567890123456789012\",\n \"type\": \"click\"\n }\n ],\n \"page\": \"example.com/pricing\"\n}"
headers = {"Content-Type": "text/plain"}
response = requests.post(url, data=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'text/plain'},
body: '{\n "deviceType": "phone",\n "events": [\n {\n "creativeId": "clcr1234567890123456789012",\n "type": "impression"\n },\n {\n "creativeId": "clcr1234567890123456789012",\n "type": "click"\n }\n ],\n "page": "example.com/pricing"\n}'
};
fetch('https://{baseurl}/api/v2/client/{workspaceId}/creatives/events', 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://{baseurl}/api/v2/client/{workspaceId}/creatives/events",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\n \"deviceType\": \"phone\",\n \"events\": [\n {\n \"creativeId\": \"clcr1234567890123456789012\",\n \"type\": \"impression\"\n },\n {\n \"creativeId\": \"clcr1234567890123456789012\",\n \"type\": \"click\"\n }\n ],\n \"page\": \"example.com/pricing\"\n}",
CURLOPT_HTTPHEADER => [
"Content-Type: text/plain"
],
]);
$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://{baseurl}/api/v2/client/{workspaceId}/creatives/events"
payload := strings.NewReader("{\n \"deviceType\": \"phone\",\n \"events\": [\n {\n \"creativeId\": \"clcr1234567890123456789012\",\n \"type\": \"impression\"\n },\n {\n \"creativeId\": \"clcr1234567890123456789012\",\n \"type\": \"click\"\n }\n ],\n \"page\": \"example.com/pricing\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "text/plain")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{baseurl}/api/v2/client/{workspaceId}/creatives/events")
.header("Content-Type", "text/plain")
.body("{\n \"deviceType\": \"phone\",\n \"events\": [\n {\n \"creativeId\": \"clcr1234567890123456789012\",\n \"type\": \"impression\"\n },\n {\n \"creativeId\": \"clcr1234567890123456789012\",\n \"type\": \"click\"\n }\n ],\n \"page\": \"example.com/pricing\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{baseurl}/api/v2/client/{workspaceId}/creatives/events")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'text/plain'
request.body = "{\n \"deviceType\": \"phone\",\n \"events\": [\n {\n \"creativeId\": \"clcr1234567890123456789012\",\n \"type\": \"impression\"\n },\n {\n \"creativeId\": \"clcr1234567890123456789012\",\n \"type\": \"click\"\n }\n ],\n \"page\": \"example.com/pricing\"\n}"
response = http.request(request)
puts response.read_bodyBody
Response
Always, whether or not anything was counted.
Was this page helpful?