I installed the Google Analytics tracking code in an intranet site, it works properly. But my concern is, are there any security risks of using it for an intranet site? simply, is it ok to use Google analytics for an intranet site?
There are few security risks linked to Google Analytics. Your SharePoint site will not be hacked because you use Google Analytics. You cannot be 100% sure, but the only "safe" way is running log processing software on-premise or use built-in Web Analytics.
However, I believe the largest risk are concerned with the legal aspect of possibly exposing internal information to third parties. For instance, the page title "X aquires Y sometime in the future" might be logged to Google Analytics. I cannot advise you here, so this is something you have to discuss with your legal department.
As Jan Maximilian Winther Kristia points out, there aren't that many security risks using Google Analytics. As it tracks traffic on an internal site, you would want to make sure that Google Search Bots are disallowed. This can be done by making a Robot.txt file which tells Google's search bots to not index this site.
Another option (which is highly recommended, taking in to consideration that it's an internal site) is to use SharePoint Web Analytic, which tracks pretty much the same things as Google Analytics does, but which doesn't "publish" it to the world.
Google Analytics does have some security / privacy concerns if you use it on an Intranet site - here's a brief writeup:
They state "The Google Analytics terms of service, which all Google Analytics customers must adhere to, prohibits sending personally identifiable information (PII) to Google Analytics. PII includes any data that can be used by Google to identify an individual, including (but not limited to) names, email addresses, or billing information."
They seem to really want you to feel secure with them. See more at https://www.google.com/analytics/learn/privacy.html