Tracking pixel. How does it work?

What is a tracking pixel?

A tracking pixel is just a small image (1×1) that allows you to send to the server (or an external one) some information about the action the client is being doing on your site. The src attribute of the image will be the URL of the script where the pixel must be processed. Tracking pixel is a specific implementation of a web bug.

How do I include a tracking pixel in my site?

To include a tracking pixel, you just have to create an image that has an URL as the SRC attribute of the IMG element. For example:

<img src="" alt="" width="1" height="1" />

On the script located in you can process the request and then use the params you receive by GET to process any information.

Should the response returns an image? If you are making a request, the server will be waiting for a response so, you need to give a response. I can give you two options:

  • Return a header with 204 code (no content)
  • Return an empty 1×1 transparent GIF.

You can think the first option is better, because you are sending no data. But, what does a transparent 1×1 GIF weights? 35 bytes. The worst connection in the world won’t appreciate any change.

Why would I need a tracking pixel?

A tracking pixel is used to store information about a user action. It could involve any action that a user takes in your website. It can help to answer this questions:

  • How many times a user arrives to shopping cart page?
  • How many users has cookies deactivated when they access the site?
  • When a user arrives at shopping cart, how many products (average) has been added to the cart in that moment.
  • How many purchases have been on my site

Lets see an image of a typical “conversion tracking pixel” implementation. A conversion is the moment where a user has made the end-action your website is expecting (subscribe to a newsletter, buy a product, register as a user,…). When the user arrives to confirmation page, then the pixel is sent to the server and processed.

Conversion Tracking Pixel Img


Are there any alternatives to tracking pixel?

Of course. For example, Google Analytics uses mainly tracking code with javascript. There is a javascript code that requests for a javascript file (method), that will be the responsible of processing the information that is sent to it. Pixel tracking is the simplest way of tracking and with tracking code Google Analytics can have a robust API that offers a lot of methods to all their users that can fit any need a an API consumer must need.


  • Share post

Leave a Reply

Your e-mail address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.