3
2 Comments

Developers: How can I build a tracking pixel in python?

I want to build a tool that will allow users to see all their customer data in one place. to do that, I need to know how the tracking pixel is created.
thanks in advance.

on November 7, 2019
  1. 5

    A tracking pixel is just a route on your app that returns a pixel instead of any content. To do it, just save whatever data you need to save, and after you've done that return base64.b64decode("R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7") while setting the following headers (which instruct the browser to serve the pixel as an image and to avoid caching it):

    Content-Type:image/gif
    Expires: Mon, 01 Jan 1990 00:00:00 GMT
    Cache-Control: no-cache, no-store, must-revalidate
    Pragma: no-cache
    
  2. 1

    I've implemented it to check whether people opened my e-mails or no. You can see and example in this repository