someone just asked this question today …
http://wordpress.org/support/topic/49392
also google tell you where to place it :
Copy the following code block into every webpage you want to track.
Click in the box below to select all code. Next, copy it. Then, paste the code segment after the <head>, <meta> tags and before the </head> tag on each page you are planning to track.
in your themes header.php should be fine …
This raises an important point about the structure of WordPress and its theme system.
If I wanted to use Google Analytics, or any other kind of web service that requires a similar call to a remote script, then I have to duplicate the call in all of the themes I wish to use. Is there a way to set this up so that I can store my links to remote services like this external to the themes? This is too much maintenance to bother with, otherwise.
could you put the code itself in a .js file or a php file and have it called somwhere in your header? then when called, would run whateve ryou put in the file whether it is that or another?
Too much maintenance if you switch theme everyday. In that case, a plugin that utilize the hook wp_head
can maintain a single source that could be included in any active theme.
Moderator
James Huff
(@macmanx)
Volunteer Moderator