Dynadot โ€” .com Registration $8.99

Put Google Analytics in headers/footers?

Spaceship Spaceship
Watch

Dario D.

Established Member
Impact
1
Anyone know if you're supposed to put the Google Analytics code in headers/footers that are IFrames?

If you look at my front-page here, all of the links are in inline-frames (which themselves are their own HTML pages), and I'm not sure if they need their own Analytics code or not.
 
Last edited:
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Unstoppable DomainsUnstoppable Domains
I put it in the footer. Only place it once on your page, it will help.

Always the best place.
 
0
•••
By putting in the footers, you ensure:

1. Your page content loads first.

2. The stats are counted only after a full page load.
 
0
•••
definitely put it in the footer - that is a best practice
 
0
•••
Okay, thanks. But also, are you sure that'll properly report page hits? Is there a chance that putting the code in the footer will result in GA reporting a million footer visits, and nothing else?
 
0
•••
Update: Okay, sure enough, GA now shows that people are visiting the footer IFrame like crazy (linkbar.html), but not any of the relevant site pages. :(

Anyone know if there's a way to force the pageviews to reflect the master page, not the IFrame?
 
0
•••
did u try putting the code just in the footer of the original page (where u have the iframe code)?

google has always been one smart cookie when it comes to anything, and id be VERY surprised if they didnt read/register content that was inside an iframe - try removing it from the actual iframe page and putting it only on the main page.
 
0
•••
Yeah. When the code is in [main-page-name].html, everything works fine. But when I only have it in [footer].html (loaded on "main page" as an IFrame) GA says that all pageviews are for [footer].html, and I no longer see what's happening on "main page".
 
Last edited:
0
•••
I wouldn't put anything google related in an iframe :)
 
0
•••
I also go for footer.

My idea is that my site will still run properly even without that being loaded first. :)
 
0
•••
Google Suggest you to put in footer. Agree with Halycon.Spinste's post, you need to load your content first before google script
 
0
•••
people who say that you should put your code in the footer are not understanding your problem.

let me see if i have it right:

you have a design (homepage, example, is index.html) that consists of multiple parts displayed using iframes (such as main.html, header.html, and footer.html). your question is whether you should put the google analytics code in index.html or footer.html, NOT if you should put it in "the footer of the website"

the code should be included at the bottom (right before the </body>) of your index.html page. (this way, your <iframe> tags are found ABOVE your analytics code). the individual pages (main.html, header.html, footer.html, etc) should NOT need the analytics code


am i correct in interpreting your problem/question?
 
0
•••
Dynadot โ€” .com Registration $8.99Dynadot โ€” .com Registration $8.99
Appraise.net
Unstoppable Domains
Domain Recover
DomainEasy โ€” Payment Flexibility
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back