Forum Moderators: open
Sounds complicated? Not really, since it is actually the exact situation the module authors chose for their API tutorial, so it's actually not only written, but explained as well, so hopefully you can tweak it for your needs.
check out: [drupal.org...]
Many things will cause a discrepancy between Google and server-based stats because GA is based on Javascript and the internal stats are based on actual HTTP requests.
So that means GA does not count hits by users who have Javascript turned off (5-10%) and scrapers, bots, search engines and so on that visit your site but do not interpret Javascript.
If you want to know how much load on your server is being caused by bots, then GA is LESS accurate, for example. Anyway, it's a big topic and people far more knowledgeable than I have been debating it recently in this thead:
[webmasterworld.com...]
There's a whole weekend's worth of reading and pondering in there!