Okay, so here is the deal... I came up with this handy, dandy online newsroom app, that has a mailer service. The goal, cut down on the number of emails sent to all users of the company from 5 cagillion, bazillion to one.
What does it do, well it basically is your typical newsroom app, with categories, defined posters, and defined post approvers. Approved stories, of course, can be viewed via the application interface. Essentially people submit their would-be email announcement to this application and then once a day, at a specific time, an email is sent out, via a windows service, to all the users of the company, specifying headlines for any relavent information and highlighting the items for the current day.
The end result... big win in the eyes of the internal marketing folks, which of course bubbles up to the appropriate VP. Then, the inevitable happens. Email from the VP asking, "Can we track how many people open this email??" CRAP!! Well, tracking email stuff I know nothing about, but tracking websites, that I can handle!
Enter, Google Analytics. I have heard of it, and it is used to track and trend the external website for the company, but not anything internal. From what it looked like, Google Analytics wanted an FQDN when you set up a profile, and we use no such thing for intranet sites where I work for two reasons. 1) The end users here are not only a little dull, but lazy. I mean, who wants to type all those characters anyway. 2) The supported browser is IE which drops network credentials and prompts for a user ID and password for FQDNs that require authentication, unless you set them up in the intranet zone. Umm... can you say group policy nightmare for the engineers? Anyway, setting an FQDN for the site was not an option. So I turned to the IT staffer's handbook, Google.
I found a nice blog article by Mike Knowles (http://mikeknowles.com/blog/2009/07/11/EnableGoogleAnalyticsPageTrackingInASingleNameIntranetSite.aspx) explaining that this was possible by calling the _setDomainName method of the Google Analytics tracker object (<object>._setDomainName("none")). So I was off and running, but when I got the script, it looked nothing like what he had in his example, but rather looked like this:
Okay, so now what is going on? Well what is happening is the _gaq object is essentially a FIFO queue of commands that will be run by the Google Analytics tracking API. Documentation for the push method can be found here. Essentially, I needed to push the _setDomainName method into the list of commands before the _trackPageView method, as Mike's article suggests. So I modified my code to look like this: