People talk about pixels all the time in digital advertising, but how does it actually work?
Let’s start with an example using retargeting to illustrate the value and inner workings of the pixel. Retargeting ads are the ads that follow you around the Internet, showing you ads for things you already looked at. These are probably the most effective ads that you can buy. The way they work starts with a pixel. Let’s say someone wants to use the Google Display Network to show their retargeting ads. To make that work, Google has to drop a cookie on the user that identifies that user as having visited that page. Cookies are security restricted in how they work, though: Cookies can only be dropped for your domain and they can only be read by your domain. So if Google wants to note that I visited Expedia.com, Google has to have “a Google thing” on Expedia.com, because Expedia cannot write cookies that Google can read.
How does that technically work? It is actually quite simple. The command for a server to set a cookie is “Set-Cookie:”. It then takes a key-value pair like “Set-Cookie:Favorite_color=blue”. So you will note that there is no domain setting here. So the Expedia server can set a cookie, then the browser records the domain that set the cookie and then sends that cookie along with the HTTP request any time that domain receives a request. For ad targeting, you then read the cookie on every request and use the cookie to determine what ads should be displayed.
So if you visit Expedia and Expedia wants to serve you an ad, how does Google tag you for future ad serving? A pixel. Basically, what they do is give Expedia a 1×1 image tag that Expedia puts at the bottom of the page and then when that image loads, because it is calling Google’s server, Google can drop a cookie on you.
This same principle works for more general behavioral targeting. If I want to create a cookie pool of people who love org charts, I could put a pixel on Cogmap.com and then every time my pixel fires, I cookie a person that loves org charts and then I am able to target them based on the cookie at a later time.
So here is an example of a simple, simple pixel:
<img src="https://domain.com/pixelserver.php?[KEY]=[VALUE]" height="1" width="1">
And then here is an example of an incredibly simplistic pixel server:
<?PHP header("HTTP/1.1 204 No Content"); list($cookie_name,$cookie_value) = explode("=",$_SERVER['QUERY_STRING']); setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/"); // 86400 = 1 day exit;
So you can see here, the image tag is not actually an image at all, it is a request for a dynamic PHP file. Then the pixel server returns a “No Content” HTTP response, but sets a 30-day cookie with whatever key-value pair is passed.
It is that simple!
Does this totally fascinate you? Remember, my book is for sale on Amazon!