Use Web Bugs To Track Users Online
A web bug (also known as a Web beacon) is a very important tool commonly used by online advertisers as a marketing or advertisement analysis tool for tracking and monitoring the activity of users on a website or marketing content i.e.: blog or email. An expert advertiser inserts, a web bug in his content (usually on a website and email) to track how many people opened a particular content, on which application, and country his content is being viewed. So, whenever the advertisement is displayed by a third party just know that you are being tracked for marketing and advertisement analysis purposes.
Web bug tools are provided freely or premium mostly by CRM service providers like Hubspot CRM, Freshsales CRM, Salesforce CRM, and other Live customer support or Chat script service providers. However, a Web bug in PHP code can also be used for this tracking if tracking service by CRM provider is not available.
Information that a bug web tool delivers to make hackers or security engineers use it as an information-gathering tool. Whenever a visitor of a website or email recipient visits a website or opens an email in which a Web bug PHP code is inserted, the Web bug will run and send information back to a website owner or email sender. In Web Bug PHP code, information captured by the Web Bug is stored directly in a database.
Information capture and storage in the database by Web bugs include:
- The IP address of the person who visits the web page or opens the email
- Application the person used to view the website or open the email
- Date and Time when the web bug was viewed
- The URL of the web page where the web bug is inserted
How to Insert and Use a Web Bug on a Web Page:Â Web bug PHP code can be placed or included in web page code. Simply place or include below php code in a web page.
Step 1: Copy the below code to create table in the mysql database on your web server
CREATE TABLE IF NOT EXISTS `webbug` (
`id` int(10) unsigned NOT NULL auto_increment,
`ip` varchar(45) default NULL,
`host` varchar(255) default NULL,
`referrer` varchar(255) default NULL,
`date` date default NULL,
`time` time default NULL,
PRIMARY KEY (`id`),
KEY `index_2` (`date`),
KEY `index_3` (`time`)
) ENGINE=MyISAM AUTO_INCREMENT=1001 DEFAULT CHARSET=latin1;
Step 2: Copy and save the below php code as webbug.php in your web server
<?php
@ $db = new mysqli(‘localhost’, ‘user’, ‘password’, ‘database’);
if (mysqli_connect_errno()) {
//echo ‘Error: Could not connect to the database..’;
//exit;
}
if (!empty($_SERVER[‘REMOTE_ADDR’])) {
$ip = $_SERVER[‘REMOTE_ADDR’];
$host = gethostbyaddr($_SERVER[‘REMOTE_ADDR’]);
$referrer = $_SERVER[‘HTTP_REFERER’];
$date = date(“Y-m-d”);
$time = date(“H:i:s”);
$sql = “INSERT INTO webbug (id,ip,host,referrer,date,time) VALUES (null,’$ip’,’$host’,’$referrer’,’$date’,’$time’);”;
$db->query($sql);
}
?>
Step 3: Paste code or include code in your PHP code
Use the PHP include method: include(“webbug.php”);Â to include the webbug.php file OR paste the entire PHP code at the beginning of the web page code.
How to Insert and Use a Web Bug on Email: To insert a Web bug on email, there are two ways one can insert the Web bug email (Text Link or Image loading method). Some email services prevent automatic images and manually warn the user to load the image on the page. The image loading method is more common and repeatedly used than Text Linking.
Note: After creating webbug.php in a web server then use, the URL must look like this: https://yourpage.net/tracking-or-whatever/webbug.phpÂ
Copy url location of the Web bug and use it to redirect an image URL to the web bug URL OR embed the web bug URL in a text link included in the email body.
Option 1: Image Loading method
Upload an image, namely webbug.gif file URL will be: https://yourpage.net/tracking-or-whatever/webbug.gif and redirect it to the Web bug php file: webbug.php which URL is: https://yourpage.net/tracking-or-whatever/webbug.php
Whenever the webbug.gif file is load will always automatically redirect to the webbug.php file. It is advisable to upload and use a very small image as webbug.gif. When the image is loaded, the image will show and systemically redirect to webbug.php without loading any page but the image in the email.
webbug.gif image must be placed in the body message of the email as: <img src=
"https://yourpage.net/tracking-or-whatever/webbug.gif"
border=
"0"
alt=
""
/>
Option 2: Text Linking Method
Insert URL in a text as a text link directly to a page where a Web bug is running or included. So, when the email recipient clicks on this link it redirects and opens a page where a Web bug is inserted. This method is also known as the phishing method used by malicious hackers to deceive the victim into the click of a text link to redirect the victim to loading a harmful program