ItSolutionStuff.com

Pixel Tracking Code with PHP Example

By Hardik Savani • May 14, 2024
PHP

pixel tracking technology is use when you need to give your commerce websites or something else that you need to give that site banner or add on another website. we can use pixel tracking technology because which can help to count impressions. but if you want to use pixel tracking technology code in your wesite than you can do following way.

In bellow example i did craete one banner image for my site products add. i will give html code for display my site product banner in his site. so in this example i use pixel tracking technology for the impressions. so first lets give following code like this way. this code you can put in another websites.

Example HTML Code:

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<meta name="viewport" content="width=device-width, initial-scale=1">

<title></title>

</head>

<body>

<a href="http://test.hd/adslink" target="_blank">

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

</a>

</body>

</html>

Above html code you can you any website as banner or ads. But it is important to track this code using bellow code. when above html file code will run then it will track following file. so let's see.

Track By PHP file : getbanner.php

<?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);

?>

I hope it can help you...

Tags: PHP
Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

How to Find Number from String in PHP?

Read Now →

How to Extract All Email Addresses from String in PHP?

Read Now →

How to Upgrade PHP Version from 7.4 to 8 in Ubuntu?

Read Now →

PHP Explode Every Character into Array Example

Read Now →

How to Remove Last Element from Array in PHP?

Read Now →

PHP Curl Request with Username and Password Example

Read Now →

PHP Curl Get Request with Parameters Example

Read Now →

How to Connect SSH using PHP?

Read Now →

How to Convert XML File to Array in PHP?

Read Now →

8 Advantages of PHP Web Development Services

Read Now →

How to Partially Hide Email Address in PHP?

Read Now →

How to Get Difference Between Two Dates in PHP?

Read Now →

Codeigniter Curl Post Request with Parameters Example

Read Now →

Codeigniter Get Last Executed Query Log Example

Read Now →