Implementing the Quantcast Conversion API
  • 30 Jul 2024
  • 3 Minutes to read
  • Contributors
  • Dark
    Light

Implementing the Quantcast Conversion API

  • Dark
    Light

Article summary

Quantcast Prerequisites

IP and User-Agent Information: Collect the user's IP address in IPv4 or IPv6 format and the client's user-agent string and send that to Quantcast on the server side.

Page Information: The entire document URL of the web page you want to track server-side.

Page Referrer: The full URL of the page that referred the user to the page where the event occurred. This is not the value of the Referrer header on the request coming into the server container.

User Identifier: If available, a user ID can be a hashed email, your unique client ID, or an ID from an IP provider (like LiveRamp, ID5, etc.).

User Consent: Ensure that you obtain user consent on your web page and pass it to the server along with the server request. Quantcast supports TCFv2, UsPrivacy, GPP, and GPC privacy signals.

Request Format

GET: https://pixel.quantserve.com/pixel

Headers

Key

Required

Description

X-Forwarded-For

User’s IP address in IPv4 or IPv6 format. More

information about the header here.

Eg:172.217.22.10

User-Agent

The user agent is obtained from the user-agent header incoming to the server. More information about the header here.

Eg: Mozilla/5.0 (Linux; Android 13; SM-S901U)

AppleWebKit/537.36 (KHTML, like Gecko)

Chrome/112.0.0.0 Mobile Safari/537.36

Sec-GPC

Indicates whether the user consents to a website or service selling or sharing their personal information with third parties. The value should be forwarded to Quantcast as the partner server receives it.

Path Params - Delimited by “;”

Field Name

Required

Description

r

Random non-negative integer within the range of 0 to 2147483647 for cache busting.

Eg: 708453774

a

The Quantcast assigned account id, called p-code.

Eg: p-hTG3d_rXG5uFA

ref

Referring URL to the current page. It should be url-encoded.

Eg: https%3A%2F%2Fexample-referrer.com

url

Client URL of page where the call originated (the web page URL, not server URL!)

Eg: https%3A%2F%2Fexample.com

source

Indicates that the call was initiated on the server side. Should be hard coded to source=server

gdpr_consent

Consent information that was collected from the user. Required for EU users only.

gdpr

A “1” Indicates that GDPR applies to the request; a “0” indicates that it doesn’t apply. Required for EU users only.

labels

Comma-separated labels describing the event of the conversion funnel.


Eg: _fp.event.PageView,_fp.event.AddToCart


All marketing labels should start with _fp.event. If they are going to be used on campaigns.

uh

SHA256 hashed version of customer email for the current user.


Eg:7dcb0cd247aa94896e665c337696a7b e18d387a78d6d55b4854b7ff7d59250422

uht

A value indicating the type of the value of the user-hash passed in the ‘uh’ parameter.


It should be hard coded to uht=0 If uh property is provided with a hashed email.

us_privacy

The US privacy string if available from the web page.


Eg: 1NNN

gpp

Global Privacy Platform String

gpp_sid

GPP Section ID

d

Client domain of page where the call originated.


Eg: example.com

dst

Indicates if the user's timezone uses daylight saving. 0 if the user’s tz doesn’t use daylight saving and 1 otherwise.


Eg: 1

et

Epoch time in milliseconds.


Eg: 1712236770434

tzo

Timezone offset from UTC in minutes.

Eg: -60

orderid

Your unique identifier for a customer order.

revenue

The total value of the conversion. (required for ROAS)

currency

ISO 4217 currency code (ex "USD") as a string

pcat

The product category of the event.

customer

The customer type/segment who triggered the event.

Sample URL

https://pixel.quantserve.com/pixel;r=90624973;labels=_fp.event.InitiateCheckout

;a=p-fdPOEe5CwS0oM;url=https%3A%2F%2Fwww.quantcast.com%2Fuser%2Fac

count;ref=https%3A%2F%2Fwww.quantcast.com%2Fads%2Fmanage;uh=7dcb0c

d247aa94896e665c337696a7be18d387a78d6d55b4854b7ff7d5925042;uht=0;fpa

n=0;fpa=P0-384136544-1651838747625;gdpr=0

2 SHA256 hash of [email protected]

No tes:

1. Path params are delimited by semicolons. For instance, Quantserver's server expects the following string to send uh and uht.

uh=7dcb0cd247aa94896e665c337696a7be18d387a78d6d55b4854b7ff7d5925042;uht=0

2. Path params are separated from the path by a semicolon. For instance, in the above sample URL, https://pixel.quantserve.com/pixel is separated from r=90624973;labels=_... by a semicolon.

Response

Status

Respons/Description

200

content-type: image/gif

Returns a small binary response which should be discarded.

302

Redirect the http request.

Status Codes

All status codes are standard HTTP status codes.

2XX - Success of some kind
3XX - Redirection
4XX - Error occurred in the client’s part
5XX - Error occurred in the server’s part

Examples

cURL

curl -I

'https://pixel.quantserve.com/pixel;r=1325268613;event=refresh;labels=_fp.event.PageView,_fp.event.HomeP

age;a=p-0tYGNqnar28h2;url=https%3A%2F%2Fwww.quantcast.com%2F;fpan=0;fpa=P0-2077827324-171441

3287550;gdpr=1;gdpr_consent=CP91N4AP91N4AAKA0AENDgCsAP_AAEPAACiQg1QYwAEAALAA6ADcAJYATgA

ogCcAFGAMQAcwA6AB2gE0AKMAY0AygBrgDjAHZgPgA-ICFgEigKfAVCAqUBZoC1gF5gMkAZMA2ABusDiwOOAc

nA5YDmAHNAOcAc9A6EDo4HTAdXA60DsAHZQO3A7iB3QHfwPCA8gB5UDzAPQAekA9aB7AHuQPeA9-B8IHzwP

pA-wB9wD8YH7gf9BAAECYIFgggBBOCCoIOAQfghCCFEEKwQxAhpBDYEPQIfwRBBEMCI0ESQRKgiYCJsETwRUgi

sCLIEXIIvgjEBGSCMwI0QRqBHMCOoEeII9Aj4BH-CQIJCgSHgkSCSEElQSbgk6CUMEpASyglqCW8EuQTAAmFBM

QExgJkQTKBMuCZoJowTTBNaCbAJvQTgBOIINQg1QXAAEAALABwAJwAUYA5gB0AE0AR4AkUBT4CoQFSgLzAZIA

yYBqoDdQHFgOPgcmBykDlgOXAc6A58B1gDtgHcgPBAeKA8eB5IHlAPaAfFA-QD5QH0wPrA-6B-wH7gQBAgIBAw

CB4EEYIJggoBBgCDYEIQIUAQrghaCF4EMQIZwQ5BDqCHgIegQ_AimBGACNIEawI3gRxAjoBHYCPYEfQI_gSEAkQB

IoCRsEkASVgkwCTIEo4JUAlUBLCCWYJaQS3BLiCXQJdgS-gmACYIEwwJigTHAmTBMsEzgJpATUAmxBNsE3IJvAm

-BOEIKAQagAAAAA.f_gAAAAAAAAA;us_privacy=1-- ;ref=;d=quantcast.com;et=1714413291988;tzo=-60' \

-H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko)

Chrome/124.0.0.0 Safari/537.36' \

-H 'X-Forwarded-For: 172.217.22.10'

Java

byte[] encryptedEmail = MessageDigest.getInstance("SHA-256")

.digest("[email protected]".getBytes(StandardCharsets.UTF_8));

final StringBuilder hashedEmail = new StringBuilder();

for (int i = 0; i < encryptedEmail.length; i++) {

final String hex = Integer.toHexString(0xff & encryptedEmail[i]);

if(hex.length() == 1)

hashedEmail.append('0');

hashedEmail.append(hex);

}

StringBuilder urlBuilder = new StringBuilder("https://pixel.quantserve.com/pixel")

.append(";r=").append(ThreadLocalRandom.current().nextInt(1000000, 9999999))

.append(";a=").append("p-datasetid")

.append(";source=server")

.append(";labels=").append("_fp.event.PageView,_fp.event.HomePage")

.append(";url=").append(URLEncoder.encode("http://www.domain.com/path?query",

StandardCharsets.UTF_8.toString()))

.append(";fpa=").append("<UNIQUE_CLIENT_IDENTIFIER>")

.append(";fpan=0")

.append(";uh=").append(hashedEmail)

.append(";uht=0");

URL obj = new URL(urlBuilder.toString());

HttpURLConnection con = (HttpURLConnection) obj.openConnection();

con.setRequestMethod("GET");

con.setRequestProperty("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36

(KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36"); // USER UserAgent

con.setRequestProperty("X-Forwarded-For", "152.134.12.1"); // USER IP

int responseCode = con.getResponseCode();

assert responseCode == HttpURLConnection.HTTP_OK;

Support & Feature Requests

If you need assistance, please contact your Quantcast Account team. If you have feature requests, please reach out to [email protected], and we can set up a time to discuss them with you.

Conversion API FAQs can be found here.


Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.
ESC

Q, facilitating knowledge discovery through conversational intelligence