1

all I am trying to create Google Analytic clone. I know how to get information about the browser location IP and other similar things in PHP

What I want to know is how to create a java-script which sends this information from any website where my code is placed on my server ???

What is the minimum security requirement to create a tracking JavaScript code like google analytics?

redirect users to different pages based on session data in PHP?

Or in other words, do I have to send an ajax request to my server?

Is there any available solution already available subject to java-script?

Lonare
  • 3,581
  • 1
  • 41
  • 45

1 Answers1

2

Most analytics tools generate a url with query string parameters attached to it and then output a 1x1 image pixel, with the img src as the url. Your server would then receive and store the data. The only thing returned is the actual 1x1 pixel. This is the common method because in the event a site does not have js enabled, you wrap a hardcoded img to your server in noscript tags and still get basic info like page view.

But is there a reason why you are wanting to build your own analytics script instead of use an existing one? There are a number of 3rd party ones available, including free ones. Alternatively there is Piwik, which is a free and open source solution if you want to build off it and not have to start from scratch.

CrayonViolent
  • 32,111
  • 5
  • 56
  • 79