Artículo en español: Comprobar el marcado de Google Analytics y Nielsen

In this post we analyse how to check that we’ve set correctly the Google Analytics and Nielsen tracking code (or others with a litle changes).

To do this we’ll use php and a sitemap from the website we want to check.


CheckTracking allows us to check automaticaly that we’ve set correctly the Google Analytics and Nielsen tracking code.

Until the script is not connected directly to a web spider, we need to pass a sitemap to the php script. This script reads the sitemap, load each url and search for the Google Alnalitics and Nielsen SiteCensus tracking code.

On finish, it shows an html table report with the detail of each sitemap url.

Nowadays (Version 0_0 ) it shows:

  • Header status: ok/302/404
  • Google Analytics (classic version – no ajax):
    • If the tracking code is included.
    • Account key.
  • Nielsen SiteCensus:
    • If the tacking code is included.
    • ContentGroup var: _rsCG
    • Script version: Example: src=”//

We can copy and paste this report to an excel to work with the data (segment, filter, etc..).


Stage 1: Pre-requisites

  • A sitemap
  • Apache web server.
    • php support:
    • cURL support:
      • On ArchLinux we need the php-curl package, we can install it writing on the terminal “pacman -Sy php-curl
      • Activate on the php.ini the php-curl support.

Stage 2: Publish the sitemap

We assume on this post that the sitemap is on the url:

Stage 3: Upload files to web server

In version (V 0.0) we have two files:

  • check_tracking_lib.php: file that allow us to load an url and check if the analytics codes are included without errors. We will edit this file to include/adapt/add/improve the functions and search for new analytics trackings codes (at  this time it only search for Google Analytics and Nielsen SiteCensus)
  • sitemap_lib.php: this file reads a sitemap and extracts the urls on it. At this time it mades a call to the check_tracking_lib.php and returns if each url has the tracking code included.

Stage 4: Load the sitemap

At this point we need to pass the sitemap url to the sitemap_lib.php script.

If we assume the files are on the dir we’ll call:

If we only want to check one url:

Stage 5: Check the report

After load a sitemap url, the result the appears on the report.

On finish the last one, we shall copy all the report and paste it on an excel file(improve  this is one of the TODO’s).

At this point we can segment, search or work with data more efficiently.


  1. Clean and improve code.
  2. Separate content from presentation. Create informe.php to send a sitemap and call  sitemap_lib.php and check_tracking_lib.php to check that tracking code is include withouth errors.
  3. Check that the asyncronous Google Analytics code is included (Include the function in check_tracking.php).
  4. Allow to connect a botspider and create “on the fly” report.
  5. Check other analytics codes.
  6. Improve presentation.
  7. Allow to export to CSV or Excel.
  8. Check security and XSS errors.

Download CheckTracking Analytics y Nielsen (zip – 1,4MB)



Creative Commons 3.0 , so you can edit and improve what you want while this license is respected (If you made a comment or share your work, even better)

Entradas relacionadas

Un comentario en “Check Google Analytics and Nielsen Tracking Code”

Deja un comentario

Tu dirección de correo electrónico no será publicada.