We are using cookies to give you the best experience on our site. Cookies are files stored in your browser and are used by most websites to help personalise your web experience. By continuing to use our website without changing the settings, you are agreeing to our use of cookies.

Knowledge center

How cookies and tracking pixels are created, and how do they work

< back to knowledge center

The main purpose of affiliate network is tracking effectiveness of affiliates’ marketing actions and identifying transactions. Most networks use software based on cookies and tracking pixels. Let’s take a look at how does it really work.

Why cookies are stored?

They are used to collect information about user activity on the network. They also allow remembering and identifying users (e.g. with labels: CampaignID, PublisherID). Cookies are stored in a user's web browser.

What is tracking pixel and what does it do?

Tracking pixel (also known as web bug) is a small (1×1 pixel) image and a script, which is run if a user’s browser has JavaScript enabled. Tracking pixel is usually embedded in a web page with transaction confirmation and identifies the user through the information from a cookie stored in his web browser.

Here is a tracking pixel embedded in advertiser’s website:
<img src="http://www.reklamodawca.pl/track.asp?SiteID=12981219" width="1" height="1">

Here is a sample cookie:
Set-Cookie: Count=1; expires=Wednesday, 01-Aug-2040 08:00:00 GMT; path=/; domain=afiliacje.pl

Here is how cookies are stored:
1. browser >>>>> server
A user wants to access afiliacje.pl website, so his browser submits a HTTP request, which looks like that:
GET /index.html HTTP/1.1
Host: www.afiliacje.pl

2. browser <<<<< server
The server returns to the client a HTTP response, which can store a cookie in client’s web browser
HTTP/1.1 200 OK
Content-type: text/html
Set-Cookie: name=value
Set-Cookie: name2=value2; Expires=Wed, 09 Jun 2021 10:18:14 GMT

(page content)


Here is a script sample (on a server), that stores a cookie in a user's web browser:
<script language="JavaScript">
cookie_name = "Basic_Cookie";
function write_cookie() {
if(document.cookie) {
index = document.cookie.indexOf(cookie_name);
} else {
index = -1;
}
if (index == -1) {
document.cookie=cookie_name+"=1; expires=Wednesday, 01-Aug-2040 08:00:00 GMT";
} else {
countbegin = (document.cookie.indexOf("=", index) + 1);
countend = document.cookie.indexOf(";", index);
if (countend == -1) {
countend = document.cookie.length;
}
count = eval(document.cookie.substring(countbegin, countend)) + 1;
document.cookie=cookie_name+"="+count+"; expires=Wednesday, 01-Aug-2040 08:00:00 GMT";
}
}
</script>

Here is a script sample (on a server), that reads a cookie:
<script language="JavaScript">
function gettimes() {
if(document.cookie) {
index = document.cookie.indexOf(cookie_name);
if (index != -1) {
countbegin = (document.cookie.indexOf("=", index) + 1);
countend = document.cookie.indexOf(";", index);
if (countend == -1) {
countend = document.cookie.length;
}
count = document.cookie.substring(countbegin, countend);
if (count == 1) {
return (count+" time");
} else {
return (count+" times");
}
}
}
return ("0 times");
}
</script>