Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8752939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:20:02+00:00 2026-06-13T13:20:02+00:00

I am trying to build a pixel that would track the current URL the

  • 0

I am trying to build a pixel that would track the current URL the user is on when they visit. I can use either JS (preferred) or a 1×1 image pixel. With JS I am assuming that I’d need to run an AJAX request to a PHP script to capture the info that I need and with an image pixel I am having issues getting the currently URL.

I also thought about URL encoding the current URL with JS and dynamically placing the image pixel with the encoded current URL as a query string to a PHP script, but that I can get to be very long.

If I am to go the AJAX route, which AJAX library can I use? JQuery is too bloated for this purpose.

Any other ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T13:20:04+00:00Added an answer on June 13, 2026 at 1:20 pm

    You can write a script that creates and returns a .gif, .jpeg or .png image using PHP for tracking purposes using the GD library (which is often distributed with PHP in modern versions). If you don’t have access to GD, you can always recompile PHP with GD enabled.

    Example:

    pixel.php (commented for the purposes of explanation):

    <?php
    
      // Create an image, 1x1 pixel in size
      $im=imagecreate(1,1);
    
      // Set the background colour
      $white=imagecolorallocate($im,255,255,255);
    
      // Allocate the background colour
      imagesetpixel($im,1,1,$white);
    
      // Set the image type
      header("content-type:image/jpg");
    
      // Create a JPEG file from the image
      imagejpeg($im);
    
      // Free memory associated with the image
      imagedestroy($im);
    
    ?>
    

    In a simple example, you can then call this tracking pixel using the following example URL in an email or other page:

    <img src="http://example.com/pixel.php?a=value1&b=value2&c=value3">
    

    Using variables:

    Within your pixel.php you can then parse and interpret any $_GET variables that are passed to it within the image tag, simplistically:

    if (isset($_GET['a'])) {
      // (Do|log) act on a
    }
    if (isset($_GET['b'])) {
      // (Do|log) act on b
    }
    if (isset($_GET['c'])) {
      // (Do|log) act on c
    }
    

    Apply and repeat as you need, but you can be quite sophisticated about what you do and especially as you have access to quite a lot of information about the user through being able to set vars on the $_GET string.

    A more applicable example might be:

    <img src="http://example.com/pixel.php?userid=98798&campaign=302&last=8">
    

    Tracking more than just $_GET variables:

    You can also pick up much more information using PHP, such as:

    // Server variables
    $ip = $_SERVER['REMOTE_ADDR'];
    $referer = $_SERVER['HTTP_REFERER'];
    $useragent = $_SERVER['HTTP_USER_AGENT'];
    $browser = get_browser(null, true);
    etc...
    

    and then perhaps insert into a tracking table in your database:

    $sql = "INSERT INTO campaign_tracking 
            ('when','campaign','last','ip','useragent') 
            VALUES 
            (NOW(),'$campaign','$last','$ip','$useragent')";
    

    This is a(the) basic method used widely for tracking email marketing campaigns and specifically in PHP, but the same method is applicable using other scripting/programming languages and libraries – and for other purposes too.

    Further and useful information on GD:

    • GD reference – on php.net
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to build some image algebra code that can work with images (basically
I am trying build a page, where a user can login using his google
I'm trying to build this class (to use in ASP.NET site) that will Crop
I'm trying to build up an algorithm that downloads a JPEG image from an
I am currently trying to develop a basic pixel editor application to build up
I am trying to build this very simple (visually speaking) layout using HTML/CSS that
I am trying to build a class that does many photo operations, one method
I'm trying build a regex that will replace any characters not of the format:
I'm trying to build a program which can remove an single-colored border form an
Trying to build my own user control: <%@ Control Language=C# AutoEventWireup=true CodeFile=TabMenu.ascx.cs Inherits=TabMenu %>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.