How Google Analytics stores data in a database

I am doing a Google Analytics project for my school assignment. First of all I have two questions:

1) Exactly when does Google store data in the database? When it does this, use XHR with some server side scripting language to store it in the database, or is there a way to do this using plain javascript?

2) How to get the user's IP address from Javascript? How is Google doing for Google Analytics?

Thanks for the help.

Pranz

+2


a source to share


3 answers


The Google Analytics JS code doesn't talk directly to the server - it adds the image to the page and adds all the information to send as URL parameters in the image. Browse the page with Google Analytics, the Firebug Net dashboard is working and you will see what is happening. This way the JS code does not need to design an IP address that will be passed to the GA recording servers as part of the image request.

The best official description of what's going on is in the Google BigTable paper - there are a few paragraphs that give some hint of what's going on behind the scenes.



It might also be wise to follow this Stack Overflow question to structure the database that records and reports activity.

considers

+4


a source


1) Yes. The user-side JavaScript sends the request to the server, which handles it with a native application (you can use PHP or whatever language your server is configured to call).



2) You might find it easiest to grab the IP address using $ _SERVER ['REMOTE_ADDR'].

+2


a source


(1) Google Analytics is implemented by including a so-called "page tag". This is called Google Analytics Tracking Code (GATC) and is a hidden piece of JavaScript that a user adds to every page of their website. This code acts as a beacon, collects personal visitor data and sends it back to the Google data collection server for processing. Data processing occurs hourly, although it can take 3-4 hours in real time. Not sure what they are using server side, maybe Java

(2) You need the server side to get this working - as shown below. /

/ This part gets the IP
var ip = '<!--#echo var="REMOTE_ADDR"-->';

// This part is for an alert box
alert("Your IP address is "+ip);

// This part is for the status bar
window.defaultStatus = "Your IP address is "+ip;

      

0


a source







All Articles