HTML question -- editing many pages.

For my wife’s website, I just set up an account with Google adwords, and Google Analytics (GA).

Well, GA requires that you drop a piece of javascript into every page that you want tracked.

Now, I put that code onto her index.html and onto the entry page to her catalog, but I’d like it on every page, of which there are about 150 (mostly catalog pages).

**Can you think of a good way of putting that javascript onto every single page? **

The quick answer would be an “include”, however that still requires putting the include statement on every page.

I was thinking (HOPING?) that there might be some file that you could put at the root location, and every page just reads that automatically, but I don’t think that really works.

Even if I had all of the pages on my local machine, it’s doable, like I could write a python script or something. But, I’d need to download the entire site, process it correctly, and re-upload it. Hassle.

No, I don’t think you can do that without an existing code reference inside every file. I think that you’re going to need to download and reprocess the site.

Javascript does have it’s own include syntax:



<script language='javascript' src='ga.js'></script>


So you can put the code in ga.js, and it’ll be processed by web browsers from every page. This will work out of any HTML file type, as opposed to server-side includes which generally are only run on .asp and .shtml type files.

I’d probably be doing a global search-and-replace for a common html tag that appears once per file, instead of worrying about python, but to each their own.

As long as you’re changing every file, include an include for a master include file, that way if you have to include something else again, you can change just the include file.

Unless you’re on Windows, modifying every file ought to be a breeze anyway.

There might be other similar software out there, but this is the one I’ve always used: BK Replace.

It can be a little bit complicated to use, and you might need to learn a bit about regular expressions if you don’t already know much about them.

Yeah, it smells like it’s going to be a hassle.

I’ll make sure I put an include in there if I do this.

Thanks

Could you just do a site-wide search-and-replace in your web authoring software? Like do a search and replace so that:

</body>

turns into

all-the-code-for-the-script
</body>

Then all you’d have to do is re-upload the pages.

What you just described is a server side include.

:smiley:

You could put your script in a frameset, then load all of your site into the frame.

It’s a terrible idea for several reasons, but technically, it would achieve exactly what you’re asking for. I don’t recommend it.

If you happen to be on Linux you can try Turma
Best Open Source Mac Software Development Software 2023. It’s a search and replace program that will operate on every file in a directory and subdirectory. You can search for the closing tags and replace them with the js code and the closing tags, if that makes sense.

It never got past 0.1 and hasn’t been updated in 7 years, but I have been using it for that long and find it very useful for things like this when I don’t feel like writing a script.

It would not do what he’s asking for. Google Analytics would only track the frameset page, not the 150-so other pages he’s looking to tag.
Just do yourself a favor and add an include to every page (actually, I recommend 2 - one at the top and one at the bottom). It’s a lot of work now to save hours and hours of work for the rest of the life of the site.

I assume you don’t have SSH or Telnet access to the machine containing the files.

You may indeed have to do a download, update, and upload. No matter what technique you try, that GA code has to be in the file, or it won’t work.

I assume that you’re hosting ads on each of your wife’s pages? That (strictly speaking) is called Google AdSense.

Good luck! Ask other places, too.

Also, 150 static pages? For a catalogue site? Isn’t it time to move into a CMS system of some types? Lots of free ones out there, and lots of 'em integrate with or have shopping cart features.

Ah. Good point - well, there’s another reason why it’s a terrible idea.

Make sure your hosting package does actually support SSI or PHP - not all do (I had to upgrade mine recently because the entry level package was too basic).

Second this recommendation - it was suggested to me in this thread and I was really reluctant to try it, but I took the plunge and it was definitely the right thing to do - maintaining the site (including making modifications to all pages at once, if I want) is now a great deal easier.

No. My wife is a jeweler with an online catalog. I’m using AdWords, and GA.

I might take the time to do the “include” thing. We plan on keeping the web site for the foreseeable future.

You’re talking past me – HTML-wise.

I don’t know what you mean by 150 static pages. She has a catalog that we created with some software, and uploaded the entire catalog to her site. Each piece of jewelry has it’s own page. She can make changes to the catalog on our local machine, and then upload just those changes to the site.

I don’t know what you mean by CMS system, but I just googled it, and I don’t know. The web site started small (10 pages) and pretty much remained that way until we uploaded the catalog. Messing with her web-site is just a side-project to me and I never got serious until she started doing a little business through it.
And, I just remembered something. . .it’s not really 150 pages. More like 75. We’ve uploaded a wholesale version of the catalog that I counted in the 150, but I don’t really need to track visits to that.

Anyway, thanks for all the advice.

A CMS, or Content Management System, is a way to use a single page as a template, with the equivalent of “includes” in sections of the HTML, which causes a dynamic build of the page each time it is loaded - calling the content from a database of information.

It makes it easier to build the site, as there are only a minimum number of different template pages; and easier to maintain the information, as it is all kept at one source.

The CMS I used is called fuzzylime (and as you might expect, the linked site itself runs on the system.

It’s free and it differs from most other CMS offerings by not requiring a back-end database, which makes it ideal for folks on basic hosting packages that may not include any database functionality.

It is set apart from the other few free non-database CMS offerings by sheer quality and diversity of features - the others don’t come anywhere close to the feature set of fuzzylime.

And it overcomes the biggest stumbling block of non-database CMS - scalability - by caching content pages for fast retrieval. Database-backed CMS doesn’t suffer much of a performance hit as the site grows, but other flat-file CMS tend to get sluggish once the number of pages grows (in fact one of them I looked at explicitly states that performance drops off sharply once you get past a few dozen pages).

It sounds like I work for them, doesn’t it? I don’t - I just think I happen to have stumbled across a fantastic bit of free software - and it’s turned me a bit evangelistic about it.

My site caused me headaches to set up, only because I had very specific ideas about layout - and it was a bit of a chore porting all the content into the CMS, but now it’s done, it’s incredibly easy to maintain - creating a new page on the site is something like 10% of the effort it used to be, and I can do it from any internet-connected machine.

It’s also a doddle to include site-wide scripts/includes (my Google ad footer is one) and includes that only appear on certain pages (the disclaimer text beneath video embeds is one - the stern warning about identification of wild mushrooms on this page is another)

This CMS stuff (and fuzzylime) looks pretty interesting. I’ll take a deeper look into it.

Also, I included the page in my profile if anyone wants to see what I’m talking about. It’s not much, but it has least paid for itself MANY times over.

Right now, I only have the GA script on the home page, and the main catalog page (to see a click, and to see a “good” click.)

Right now, I really don’t care about anything else, but GA recommends that you tag everything. I could see that making sense someday, but not necessarily right now.

I took a quick look at the site - very cool jewellery - I think it would be pretty simple to transfer into a CMS - your existing layout is very simple, so setting up the template would be fairly easy - and the individual catalogue pages could just be pasted in as content.
OK, some care would be required to keep images linked, etc, but the site is practically a textbook example of a site that needs a CMS.

I just looked at your site. You use frames, and Javascript for navigation. Both techniques, individually and collectively, will severely limit the site’s potential. Maintenance and upkeep will eventually bog down the site to the point you will either have to give up or pay someone else to maintain it.

I suggest you follow the advice given so far and rebuild it with a CMS system. And build it as a standards-compliant site as well.