// you’re reading...

Website Development

Add Google Analytics Differently For Sites With Frames

Make sure you look over this documentation page if you decide to use Google Analytics on a site with frames. The traffic sources for one of our niche sites weren’t showing up properly (it listed search engine traffic as referral traffic) and I couldn’t figure out why. It turns out you need to put the Analytics code in the <head> section of the frameset page in addition to the right before the </body> of the frame pages.

One other weird thing (makes sense but weird to see at first) is the way it shows page views. Instead of a single page impression, it records an impression for the frameset page and each of the frame pages. So when someone visits a page with two child frame pages you’ll see three impressions in your reports.

47

If you enjoyed this article, make sure you subscribe to our RSS feed! You can also follow us on Twitter here.

Discussion

4 comments for “Add Google Analytics Differently For Sites With Frames”

  1. God, I can’t believe there are still people using frames out there! They are so SEO unfriendly!

    Posted by Ryan | April 28, 2008, 5:40 am
  2. @Ryan

    Yes, frames are bad for SEO. That niche site contains a web application and essentially zero content. So there isn’t much for the search engines to do anyway.

    Posted by 47 | April 30, 2008, 1:37 am
  3. Hi,
    I hate frames myself since years but there are times when a person is helpless and then frames comes in handy. For my infant son, i purchased a domain from netfirms and they give free 25mb space with ads. The domain is http://www.amanwaqas.com, To get rid of the ad’s, i am using a 100% frame and loading an external page transparently under one page.
    So virtually the whole site is running in a frame.
    When it comes to Google Analytics, i am not sure what i did is wrong or right? Like all other site, i have placed the code at the end of body of each page and plus i have placed the analytics code in the head of the netfirms hosting parent page, that is loading my site in a frame.
    You can view the site, i have written the URL above and comment that it will work or not.
    What if the site will have two codes .. i dont know matters or not ..

    Posted by Waqas Nasir | March 30, 2010, 12:11 am
  4. @Waqas
    I glanced at the source for that site. It looks like you’ve added the code in the right spots so the stats will probably show up correctly.

    By the way, I moved the niche site I talked about away from frames awhile ago but didn’t update this article.

    Posted by 47 | March 31, 2010, 12:38 am

Post a comment