Now and then I get some pretty interesting questions, sent to me through my contact form. I got one such question several times, and mostly from marketers who don’t really deal with the back-end of websites and aren’t quite sure how to get Google Analytics code up on their sites.
So the question I’m tackling today is: “How can I include Google Analytics code in the footer of my pages using Dreamweaver?”
Let’s start with some basic instructions on how to include Google Analytics code on your website’s pages. If you intend to update individual pages (not recommended for large sites), simply load Dreamweaver, load the page you’d like to place Google Analytics code on and in the top of your screen click on the Code view button to get into the page’s code.

Now that you’re in the code, scroll down all the way to the bottom until you find the </body> tag. Just above that tag, copy the Google Analytics code and paste it directly before/above, like so:

Save your file(s) and that’s it. Google Analytics will start receiving your site’s data shortly, as visitors come in to your site, and you should start seeing populated reports within 24 hours.
If you work with templates in Dreamweaver, load your site’s template file (*.dwt) and follow the same steps to add Google Analytics code to your website’s pages.
Although this sounds tricky to do, it’s actually quite straightforward and usually works like a charm. The most important thing to keep in mind, however, is that your footer.php needs to include the </body> tag. Although there are workarounds, in most cases the closing body tag is included in the footer.
You can open your footer php file in Dreamweaver and you’ll find yourself in the Code view by default, after which it’s just a matter of copy/pasting the Google Analytics code just above the </body> tag, exactly like the example above.
If I put the google analytics code in my website, and then make adjustments to my site, and continually preview the local html file (which has the google analytics code in it), will that register to google visits each time I preview my site before posting it to the web?
Michael – The Google Analytics code won’t run unless it can detect a URL starting with http:// or https://, so locally hosted HTML files can’t be tracked with the default code.
It would be possible to track locally hosted pages though, on a separate note.