Third-Party Cookies (Tracking Cookie)

> Marketing > Advertising

1 - About

Third-party cookie are cookies that are set via an HTTP request that fetch a third party script embedded in a page.

Third-party cookie are cookies that have another domain than the HTML page.

This cookie are cookie identifier and are send back at every future HTTP request (fetch) of the third party script to their origin (the third-party server - advertiser).

They are also referred to as tracking cookies.

3 - See


4 - Example

  • A tracking file example (Javascript mixed with php that set a cookie)
header('content-type: text/javascript');
$uniqueId = uniqid();
setcookie("bytle_uniq_id", $uniqueId, time()+3600*24*30, '/'); 
console.log('The bytle tracking javascript was executed');
  • The htaccess to redirect an URL to tracking.js to tracking.php
RewriteBase /
RewriteRule ^tracking.js$ tracking.php

  • When this script is added to a page, it will return each time that the page is loaded the unique Id.
<script src="">
  • Unfortunately, the code below does not work because it's runned in a iframe but if you open the devtool (See below), you can see the cookie send for each request of tracking.js
var cookie = document.cookie.split(";").filter( (item) => item.trim().startsWith('bytle') )[0];
if (typeof cookie != 'undefined') {
    console.log('The bytle cookie was found with the value '+cookie.split('=')[1]);
} else {
   console.log('The bytle cookie was not found');

  • The devtool that shows the cookie sends