Tracking pixels (aka beacon, 1×1 gif, or clear gif) is a tracker that allow for tracking where a POST requests are disallowed (mostly to track Open Email), but where you can embed an image that will perform a get with data passed in query string
https://trackingapi.example.com/endpoint?att1=value1&att2=value2...
Example:
https://trackingapi.example.com/endpoint?data=<base64-ENCODED-JSON>
where:
<img id="pixel" src="https://api.example.com/pixel/track?data=xxxxthedataxxx" style="display:none">
let payload = {
"userId": "025pikachu025",
"event": "Email Opened",
"properties": {
"subject": "The Electric Daily",
"email": "[email protected]"
}
}
let encodedData = window.btoa(JSON.stringify(payload));
console.log("The payload encoded is: "+encodedData);
How to send a 1×1 image as response in php. Source
$img = base64_decode('R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAEALAAAAAABAAEAAAIBTAA7');
header('Content-Type: image/gif');
header('Content-Length: '.strlen($img));
header('Connection: Close');
print $img;
tpl_flush();