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 7434425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:50:12+00:00 2026-05-29T09:50:12+00:00

I would like to create a simple web statistics javascript code ( analytics )

  • 0

I would like to create a simple web statistics javascript code ( analytics )

but wondering whats the correct way to include referer ?

I think somehow need to implement javascript escape(document.referrer) with php inside track.php

This is what i have so far :

script on remote site:

<script type="text/javascript" src="http://www.mydomain.com/track.php"></script>

local track.php:

<?php
$str = 'document.write(\'<img src="http://www.mydomain.com/tracking.php?id="/>\');';
echo $str;
?>

local tracking.php

<?php
header("content-type:image/gif");
$ip = $_SERVER["REMOTE_ADDR"];
$browser = $_SERVER['HTTP_USER_AGENT'];
//$referer = ????
///etc...
// save results to db ...
  • 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-05-29T09:50:14+00:00Added an answer on May 29, 2026 at 9:50 am

    You want to build a list of all params, for example…

    var params = {
        resolution: screen.width + ',' + screen.height
    };
    

    …then you need to serialise them to GET params…

    var serialisedGetParams = [];
    
    for (var param in params) {
        if ( ! params.hasOwnProperty(param)) {
           continue;
        }
        serialisedGetParams.push(param + '=' + encodeURIComponent(params[param]));
    }
    
    serialisedGetParams = serialisedGetParams.join('&');
    

    …then make a request…

    (new Image).src = 'http://yourdomain.com/track.php?' + serialisedGetParams;
    

    The params you send should be stuff only JavaScript can get, such as resolution etc. Sending them via the GET params of an image allows you to bypass Same Origin Policy.

    Additionally, the image request can get information such as the IP, Referrer, etc. Examine the $_SERVER super global for a wealth of information about the request.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For a web application, I would like to create a simple but effective licensing
I'm developing a simple web quiz and using javascript, I would like to create
Question for Python 2.6 I would like to create an simple web application which
I would like to create web page which will print simple message x minutes
I would like to know if there is a way to create web pages
I would like to create simple objects at runtime (textbox, label, etc) and add
I would like to create a simple file format/DSL which would allow my users
I would like to create a simple control that inherits from HeaderedContentControl, and has
I would like to create a simple XMPP client in java that shares his
I would like to create a simple designer which looks like visual studio. Specifically,

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.