Web Analytics - Pixel (1×1 gif, Clear Gif)

1 - About

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

3 - Pro/Cons

  • Pro: Works even if POST requests are disallowed
  • Cons: Data payload is limited by the 2000 character URL length limit.

4 - Usage

5 - Syntax

5.1 - Raw data



  • Aws - Cloudfront - the request gets logged to the web log saved in S3 including some additional data provided by Cloudfront. (E.g. requester IP address and URL.)

5.2 - Json Encoded



6 - Example

6.1 - The IMG tag

  • The Img tab would be where the src is a route that returns a 1×1 pixel image

<img id="pixel" src="https://api.example.com/pixel/track?data=xxxxthedataxxx" style="display:none">

6.2 - Json Payload Encoding

  • A payload (a json)

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);

  • Result:

6.3 - Return a 1x1 image in Php

How to send a 1×1 image as response in php. Source

header('Content-Type: image/gif');
header('Content-Length: '.strlen($img));
header('Connection: Close');
print $img;

7 - Documentation / Reference

Data Science
Data Analysis
Data Science
Linear Algebra Mathematics

Powered by ComboStrap