Pixel tracking code php example

Today now in this post i will show you pixel tracking code in php. pixel tracking technology is need when we want to give our commerce websites or something else that we need to give that site banner or need to add on another website. That time we can use pixel tracking technology because which we can help to count impressions. but if we want to use pixel tracking technology code in our website than we can do this by using following way.

So now in the bellow example i did create one banner image for my site products add. And here i will give html code for display to my site product banner in his site. So now in this example i will use pixel tracking technology for the impressions. So at first let’s give the following code as like this way. On this code we can put in the another websites.

Example HTML Code:

<a href="http://test.hd/adslink" target="_blank">
<img src="http://test.hd/getbanner.php?pid=1&token=yoRyH5" width="100px" height="100px">
</a> 

So above html code we can use any our website as a banner or ads. But it is very important to track this code by using bellow code. So when above the html file code will run then that time it will track following file. so let’s see bellow.

Track By PHP file : getbanner.php

$ids = $_GET['pid'];
 $imagePath = "http://test.hd/banner/path.png";
 

 if(!empty($ids)){
 	$imagePath = "http://test.hd/banner/test.png";
 }
 

 header('Content-Type: image/gif');
 echo readfile($imagePath);

Read Also : How to count number of files in directory PHP?

Thanks for read. I hope it help you. For more you can follow us on facebook.

About Shahriar Sagor

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by Shahriar Sagor →