Tracking Code 

What is a Tracking Code?

Tracking Code – A script, often placed in the header, footer, or thank you page of a website that passes information along to software tools for data gathering purposes. Tools like Google Analytics, Google Adwords utilize tracking codes so that they can track information about users who view a site.

Google Analytics works by the inclusion of a block of JavaScript code on pages in your website. When users to your website view a page, this JavaScript code references a JavaScript file which then executes the tracking operation for Analytics. The tracking operation retrieves data about the page request through various means and sends this information to the Analytics server via a list of parameters attached to a single-pixel image request.

Because your website configuration and reporting needs might differ from a standard setup, it’s a good idea to understand the general tracking process to ensure that your reports deliver data as you expect. In this way, you can decide how to configure Analytics tracking to best suit your own website.

How Does Google Analytics Collect Data?

The data that Google Analytics uses to provide all the information in your reports comes from these sources:

  • The HTTP request of the user
  • Browser/system information
  • First-party cookies

The HTTP request for any web page contains details about the browser and the computer making the request, such as the hostname, the browser type, referrer, and language. In addition, the DOM of most browsers provides access to more detailed browser and system information, such as Java and Flash support and screen resolution. Analytics uses this information in constructing reports like the Map OverlayBrowser, and Referring Sites reports. Analytics also sets and reads first-party cookies on your users’ browsers in order to obtain user session and any ad campaign information from the page request. The Google Analytics Tracking Code also reads the DoubleClick cookie to get information about the Display Features.

When all this information is collected, it is sent to the Analytics servers in the form of a long list of parameters attached to a single-pixel GIF image request. The data contained in the GIF request is the data sent to the Google Analytics servers, which then gets processed and ends up in your reports. Here is an example of only a portion of a GIF request:

How the Tracking Code Works

In general, the Google Analytics Tracking Code (GATC) retrieves web page data as follows:

  1. A browser requests a web page that contains the tracking code.
  2. A JavaScript Array named js is created and tracking commands are pushed onto the array.
  3. An <script>element is created and enabled for asynchronous loading (loading in the background).
  4. The ga. js tracking code is fetched, with the appropriate protocol automatically detected. Once the code is fetched and loaded, the commands on the _gaq array are executed and the array is transformed into a tracking object. Subsequent tracking calls are made directly to Google Analytics.
  5. Loads the script element to the DOM.
  6. After the tracking code collects data, the GIF request is sent to the Analytics database for logging and post-processing.

Refer: Google

 

 

« Back to Glossary Index