Jump to content

Where to insert Google Analytics code


owosso

Recommended Posts

Normally I'd insert the Google Analytics code before the </body> tag.Where should I insert it in a php document? It has no closing body tag. Here's my final code in my index.php document:

</div><!-- #content -->			<?php require ($path_to_root . 'includes/foot.php'); // Include the footer HTML. NOTE: div#wrapper is closed in foot.php ?>	

Link to comment
Share on other sites

And if yu really don't have a closing body tag then your page is invalid and you should insert one

Link to comment
Share on other sites

Dilated is right, in SGML-based HTML the body tag (and some other tags) are implied and get, uh, inserted for you if you don't put them in. SGML will also assume closing tags if the situation is unambiguous.Of course, it's probably better if you put the tag in anyway :).

Link to comment
Share on other sites

You should not omit the body tag if you're making any HTML page, same as the HTML tags...
Why not? Less bandwidth, and the dom structure will end up with a <body> and <html> regardless.Synook, how is it better to use <body> and <html>? I mean, I suppose one of them might be necessary if you need an attribute on it, but otherwise they're not necessary.To the OP, I would say go either way. Either go without a <body> close tag and without the open tag as well, or use both tags. You don't need to, but it looks awkward with just the open tag.
Link to comment
Share on other sites

I think it's just nicer - it makes your code more readable, in the same way that adding comments does, and when you do need to use them later, for attributes etc., you won't get confused (you never know). And it's a good habit to get into if you are going to be using XML-based languages at some time.

Link to comment
Share on other sites

And it's a good habit to get into if you are going to be using XML-based languages at some time.
XML-based languages only require a single all-encompassing root element. XML-based languages wouldn't necessitate a <body> in comparison, maybe <html>, but not <body> or <head>.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...