Chris J. Vargo
Chris J. Vargo

Reputation: 2436

Pipe Apache Logs to Google Analytics?

Does anyone know of a piece of code that can run on a server that pipes the data from Apache logs into Google Analytics? I've got a bunch of websites that generate logs, but the users would likely object to injecting Google tracking codes into them. This might be a nice way to get the basics, what's being requested from where, and have it all sorted for me in with my other Google Analytics pages.

Upvotes: 0

Views: 2199

Answers (3)

mike
mike

Reputation: 7177

For non-Universal Analytics accounts, you can use php-ga - Server-Side Google Analytics Client -- it's essentially a server-side implementation of ga.js.

One caveat: If you want the location metrics to record something other than the location of your server, you'll need to log with a Google Analytics mobile tracking ID. Just replace the "UA" in the tracking ID with "MO", like "MO-12345678-1"

Upvotes: 1

Eike Pierstorff
Eike Pierstorff

Reputation: 32760

You can use the new measurement protocol (available for universal analytics account only) to implement a serverside solution.

Piping logs would probably not work very well (at least if you want to do a batch job - I don't think you can send a timestamp via the measurement protocol, so it would look as if all hits occured at the same time) but it shouldn't be necessary anyway, just create an url with the relevant parameters pointing to the google endpoint and sent it in the background via CURL (or similiar).

If you're in the European Union remember privacy guidelines still apply and you need to inform users and provide an opt-out link.

Upvotes: 3

halfer
halfer

Reputation: 20440

GA needs JavaScript, I think, so that various things like screen resolution can be grabbed. So even if this were possible, you'd be missing a good deal of info for some of your users, skewing your other percentages. Also, if your users are suspicious of Google, they probably would not want you to upload their IP addresses to GA.

With all that in mind, I wonder whether a self-hosted GA-like system would fit the bill? If so, try Piwik.

Upvotes: 0

Related Questions