Conversion API

Prev Next

The Conversion API is a server-to-server integration designed to augment the Live Tag. It captures offline conversion events and other performance signals that occur outside of the web browser, such as subsequent offline sales or financial service conversions that happen after a delay.

Flowchart illustrating token exchange between browser, website, and Quantserve for conversions.

Acquiring a Browser Token

To ensure the highest accuracy, it is recommended to pass a Quantcast Browser Token with your offline events. This allows the platform to link server-side conversions back to specific web activity.

There are three ways to acquire this token:

  1. Via Live Tag (Recommended): Pass the token_callback parameter. Live Tag will acquire a token and return it to your function. For example:

<!-- Start Quantcast Tag -->
<script type="text/javascript" async="true" src="https://pixel.quantserve.com/quant.js"></script>
<script type="text/javascript">
window._qevents ||= [];

_qevents.push({
"qacct": "<account id>",
"event": "PageView",
"token_callback": function(bt) {
  // bt.token contains the token
// bt.expires contains the expiration date in unix epoch time.
}
});
</script>
<!-- End Quantcast tag -->
  1. Via Quantcast SDK: You can use the quantcast-labs/events-sdk NPM package to invoke the quantcast.token function. For example:

import token from "@quantcast-labs/events-sdk";

token(“<account-id>”).then((token) => {
 // In this example, we simply send the request to the "/store-token"
// endpoint of the website. Consumers of this API must implement
// some way to store the token to send with future events, but following
// this exact example is not required.
//
// token.token will contain the browser token string to be provided with
// subsequent requests.
//
// token.expires will contain the expiration time of the token in Unix
// Epoch time. This information does not need to be provided to quantcast
// at any time in the future.
navigator.sendBeacon("/store-token", JSON.stringify(token));
}).catch(console.log);

It is important to note that, in many regions, due to privacy requirements, customers must either integrate with a consent management platform or implement data privacy practices that comply with the applicable regulations in those jurisdictions. Live Tag and the Quantcast SDK integrate directly with many standard consent management platforms, provided an approved standard consent management platform is detected on the page. When invoking the /token endpoint directly, consent signals are still required as applicable per the relevant privacy requirements.

The token endpoint accepts Transparency and Consent Framework v2, US Privacy API, and Global Privacy Platform consent signals. The endpoint may refuse to provide a valid token if the request lacks appropriate consent signals.

Parameter

Description

p

Function name enabling JSON-P support for this endpoint. When using the Fetch API, simply omit it.

a

The account id in the Quantcast platform, as with the qacct parameter in Live Tag.

fpa

A cookie from the website that is making the call. This value is important for cookieless targeting and attribution, and excluding it reduces report accuracy.

fpan

A boolean (encoded as a decimal, 0 or 1) indicating if the cookie was set in this page load.   

d

The domain that the cookie is set on.

gdpr

A boolean (encoded as a decimal, 0 or 1) indicating if gdpr applies to this request. This parameter is strictly required.

gdpr_consent

A Base64-URL encoded Transparency & Consent String compatible with TCFv2. This value MUST be provided if gdpr=1.

us_privacy

A US Privacy API string in the format of the IAB US Privacy API. This value MAY be included if a USP API compliant Consent Manager is present on the page. It is deprecated in favor of the Global Privacy Platform.

gpp

A Global Privacy Platform Consent String. This value SHOULD be provided if the page includes a GPP-compatible Consent Management Provider.

gpp_sid

A comma-separated list of section ids that applied to this request when consent was collected. This value should contain the values supplied in the applicableSections parameter of the response from any GPP-compatible Consent Management Platform.

See the "Full GPP String passing" section of the GPP Consent String Specification.

As mentioned previously, the token endpoint responds with a JSON document.

>> token(“p-0tYGNqnar28h2”).then(console.log)

{"expires":1744580688,"token":"Q0--svLRSUPWvTC1QaHEq4LNOrzQ8Hif2YD3lZITq8Sn0SaQX
AJ-M9OWWFhBqzYvsZyxMdMX7O0LO6dZ_-yxusGiAD1dKKqIp5yM03yrZTpo8Si_uGewspHZoN3s9y_V8jpvs0ae18fx8NTFEYEv7CI
NpjVvE-9W8vAeIJu"}

Reporting Offline Conversions

Offline conversion events are reported to the Quantcast Platform via POST requests to the /conversion endpoint. This API accepts a JSON document containing an array of conversion objects describing the event, including the time and origin of the event, as well as additional information about the client that triggered it. Conversion events must include a description of the user; however, many fields are optional and may include additional data to augment the event, such as event labels, revenue, an order ID, or the product category. The data model and a detailed description of each object field follow below.

Diagram illustrating user conversion process with associated data fields and events.

The conversion object:

Attribute

Type

Description

name

string

The conversion event name, required.

time

int

The Unix Epoch Timestamp (time elapsed since 00:00:00 Jan 1st, 1970) that the event occurred. When omitted, defaults to the current time.

Both epoch seconds and epoch milliseconds are accepted.

url

string

The URL where the event was triggered.

referer

string

The referring URL for the page that triggered the event.

The user object:

Attribute

Type

Description

token

string

The browser token for the user that ultimately triggered this request, as issued by the token endpoint. Optional, and when omitted, the user agent and client ip are required.

client_user_agent

string

The user agent of the client that triggered this event SHALL be provided when the token is omitted.

client_ip

string

The IP address of the client that triggered this eventID for the user who SHALL be provided when the token is omitted.

external_id

string

A cookie or customer id for the user which triggered this event. Providing this value is strongly recommended.

email

string

A SHA-256 hash of the email address of the customer. Unhashed emails are not accepted via this API and will be rejected.

The event object

Attribute

Type

Description

labels

array

An array of additional labels for the event. Event labels can be used for reporting and targeting.

orderid

string

An orderid for this event.

revenue

double

A value representing the revenue which is attributed to this conversion, in the format of a monetary value without a currency denomination. i.e. 99.95. The currency is expected to be the billing currency of the account.

product_category

string

The product category of this event.

Conversions can be reported by sending an HTTP POST request to the /conversions endpoint on pixel.quantserve.com. Only an event name and a user object are required. The user object may contain either a token or a client_user_agent and client_ip. All other parameters are optional.

> curl -X POST -H 'Content-Type: application/json' -d '[{ "user": { "token": "Q0--svLRSUPWvTC1QaHEq4LNOrzQ8Hif2YD3lZITq8Sn0SaQXAJ-M9OWWFhBqzYvsZyxMdMX7O0LO6dZ_-yxusGiAD1dKKqIp5yM03yrZTpo8Si_uGewspHZoN3s9y_V8jpvs0ae18fx8NTFEYEv7CINpjVvE-9W8vAeIJu" }, "name": "Conversion API TEST" }]' 'https://pixel.quantserve.com/conversion?a=p-0tYGNqnar28h2'