Pixel Tracking, also known as 1x1 gifs, or clear gifs, lets you record data from any website (or application) where JavaScript or POST requests are not allowed, but where you can insert an image (aka GET hit)
When a POST request is possible, please prefer the http tracking API, more convenient to use.
To send a basic event call using pixel tracking, construct a GET request to the tracking endpoint URL with the necessary query parameters. The following example demonstrates a basic event call for tracking a page view:
In the above example, replace {siteId}
with the ID of your site (aka workspace), {yourSourceKey}
with your specific source key, and value1
with the desired value for prop1
. Remember to URL encode the string values, especially if they contain special characters or spaces.
Pixel tracking allows for more complex data structures like objects and arrays. To include them in your event calls, you can nest parameters by indicating objects and their properties with square brackets for both objects and arrays. The property names are enclosed within the brackets and nested properties are further enclosed in their own set of brackets. The following example demonstrates an event call with objects and arrays:
To transform the above JSON event call to URL parameter form, follow these steps:
Start with an empty string for the URL parameter form.
Copy the key-value pairs at the top level of the JSON object (event_name
, tc_s
, token
, page_type
, page_name
) as they are, separating them with ampersands (&
).
For nested objects like user
, represent them in the URL parameter form by appending the nested key using square brackets ([]
).
For array values like user[consent_categories]
, append []
to the key to indicate an array parameter.
Include each element of the array as a separate key-value pair, appending the square brackets notation to the key as well.
URL encode the string values, such as replacing the space in Best sellers
with %20
and the @
symbol in the email address with %40
.
The transformed URL parameter form for the JSON event call would be:
Arrays of objects can also be handled in pixel tracking event calls. This allows you to include multiple items within a single event, such as a purchase event. Let's consider an example of managing an array of objects for items in a purchase event:
To include the array of objects within the event call, follow these steps:
Include the key-value pairs at the top level of the JSON object as usual (id
, revenue
, value
, shipping_amount
, tax_amount
, currency
, user
).
For the array of objects, specify the key (e.g., items
) and use square brackets ([]
) to indicate an array parameter.
Include each object within the array as a separate set of key-value pairs, preserving the structure of the objects.
If necessary, nest additional objects or arrays within the objects of the array.
Example of transforming the JSON event call to URL parameter form:
In the transformed URL parameter form, each item within the array is represented by its index, followed by the keys and values of the nested object.