I have a website made up of only html pages. Instead of copy pasting the google analytics code on every .html file, is there a better way to include the google code on every page ?
|
I see everyone recommending a server side solution for this, which is fine, but if yopu're going to have to go through all of their files and append a server side include into your pages why not just put the Google Analytics code into a separate file and include it using a
|
|||||||||||||||||
|
|
The down side to the suggestions so far is that they all require visiting each html page to add code. Sounds to me like the short answer is that you DO have to touch every page. Ok, maybe I am being overly simplistic, but what about using a find & replace utility? Chances are that whatever software you use has find & replace functionality, and you can add something to every page quickly. For instance, if you want it to be the last thing before the tag, just find that tag and replace it with the code you wish to insert plus the tag. Placing the GA code in a js file or a ssi file might be a big help down the road for any changes you need to make. That way you would only have to touch one file instead of revisiting all of them. |
|||
|
|
|
It's been a really long time since I've used a WYSIWYG editor (probably 10 years) but I seem to recall Dreamweaver (and perhaps others) allowed you to add "template" items which would populate to every page listed in the current site. If you're using an editor such as this I'd look through their documentation or ask in their support forums first. |
|||
|
|
|
FYI using Toby suggestions this is the code to put in ALL your HTML pages just before the
Then you create a file called
With PHP it works in the same way, simply add this PHP code in ALL your HTML pages just before the
|
|||
|
|
Server Side Includes could be your way forward. http://en.wikipedia.org/wiki/Server_Side_Includes They are generally ignored because scripting languages like PHP do a better job, but these will get the job done for you. |
|||
|
|
I think the quickest is to make footer.php for example and add the code there. After that or before that footer have to appear as element in every page of your website. |
|||||
|