What are the best practices for delivering images through PHP for tracking purposes?

When delivering images through PHP for tracking purposes, it is important to ensure that the images are not cached by the browser to accurately track each request. One way to achieve this is by adding a unique query string parameter to the image URL, which will force the browser to fetch the image from the server each time it is requested.

<?php
// Generate a unique query string parameter
$timestamp = time();
$imageUrl = 'image.jpg' . '?t=' . $timestamp;

// Output the image with the unique query string parameter
echo '<img src="' . $imageUrl . '" alt="Tracking Image">';
?>