You can put that code in the header... or you can do it in the main page template just before the closing body tag /body. Then your page will load before your counter, which may be better for your customers if StatCounter has a problem.