A Copy for Your Records

A common complaint I have heard from clients regarding Google Analytics involves losing one’s data to Google’s chasm-sized storage bins, never to be seen again. Sure, Google does provide a healthy API and a nice array of reporting, but what if you want to use log files to upload web data into a home-grown data warehouse? Also, what if unique analytics are being performed from old tools tying web data to offline metrics gathered from other systems?

As it turns out, Google provides a very simple way for anyone to collect and store his or her own copies of the image requests created using the base tag. Two additional function calls are required within the page tagging to collect these requests.

  • _setLocalGifPath(newLocalGifPath) - Sets the path for the image that will be requested from the local server.
  • _setLocalRemoteServerMode() - Tells the tag to fire an image request both to Google’s remote server and the path specified in _setLocalGifPath().

The following two functions need to be called on the pageTracker object before the _trackPageview() call, as displayed below.

Voila! Every page on your website will now be sending an image request to http://www.domain.com/path/to/image.gif, in addition to the utm.gif image request sent to Google’s servers. Once your excitement simmers down to a slow boil, one decision still remains; how and where will you host the image? The following two options exist with their own set of pros and cons.

1. Host the image on the main web server with all the other web files. In this situation, it should be very simple to request a 1x1 transparent pixel to be added anywhere on the server. The downside to including this method is that the analytics log entries will be intertwined with the rest of the image requests for the server, many times requiring some form of pre-processing before storage or back-end analysis.

2. Host the image on a new, unique web server instance. In this case, additional resources or technical know-how will be required to enable the tracking. However, once hosted properly, the web server instance will log all requests made to the image in their own neat file, removing the necessity for any processing on the logs to parse out the analytics data.

Additionally, following the base tag modifications, your new log files will be ready for any method of data warehousing or offline conversion analysis. If you need to bring additional data into your local logs, whether it be meta tag data used with other tools, or pieces of information scraped from the page and loaded into custom parameters, you can leverage Google’s custom variables to store all manner of information for internal use. Custom JavaScript can be employed to perform any number of automated tasks, reducing a multi-step overhaul of several site parameters to a quick-and-easy file inclusion - but I’ll save that for another post. Happy coding!

If you have any questions about Stratigent’s approach to Google tagging, or if you have general comments or feedback, please feel free to email me at info@stratigent.com




By Adam McArdell
About the Author:

Adam McArdell is a Senior Technical Consultant at Stratigent.

Contact Us Now