I'm doing up a WordPress theme at the moment, and I want users to be able to add Google Analytics to their site by just adding their tracking code -- you know, the
UA-20149670-1 -type number thing.
<head> of my pages, with the tracking code being set by the user via a theme option text input form.
<head>, without a tracking code, bloating up the header.
How can I code this so that the Google Analytics code only appears after the user puts in their tracking code?
Additionally, at the moment the Google Analytics code is all still in
header.php -- ideally I'd like to move it instead to
functions.php. How best would I do that?