Google Analytics breaks iWeb blog comments

Does anybody know a workaround for Google Analytics' breaking of iWeb blog comments? Apparently, from some posts I've read, StatCounter and other traffic stat services break iWeb blog comments, too... so it's apparently an iWeb issue rather than a Google Analytics issue. FWIW, I'm publishing to my MobileMe personal domain. Thanks in advance!

MacBook Pro 17, 2.6 GHz Intel Core 2 Duo, Mac OS X (10.5.6), 4 gigs RAM

Posted on Feb 12, 2009 12:54 PM

Reply
10 replies

Feb 13, 2009 6:50 PM in response to Steve Mouzon

GA code does not break iweb blog commenting system. Method of adding GA code may break it.
Anytime you post edit/process your page code (hand edit or using Automator methods), you potentially cripple iweb commenting system... this is a known issue since iweb1.

The only way that I know of is javascript that will not cripple iweb commenting system (no post editing), you can see my GA (and Statcounter) javascript widget in my site (all code is linked to my welcome page).

I'm (slowly) porting my current widgets to iweb3 widgets with full GUI, but I will not make them available

Feb 14, 2009 9:28 AM in response to Cyclosaurus

Cyclosaurus, this sounds hopeful, but I'm not adept enough to completely make sense of it... what's the address of your site? I didn't see it in your profile. When you say about your widgets that "I will not make them available," does this mean that you're not giving them away but will sell them? If so, then I'll gladly buy whatever makes GA work on my site. Please elaborate. I'm an architect and author, but not a computer guy, which is why I chose the Mac way back in the 1980's... I don't have to be.

Feb 22, 2009 4:58 AM in response to Steve Mouzon

I host somewhere else other than MobileMe, but even when I had my site on MobileMe, I had no issues with GA and blog comments.

All I did was put the GA code using an HTML Snippet. For consistency purposes, I put my GA codes in the lower left hand footer of each page. GA recognizes the code for every page on MobileMe or in a hosted environment.

My site is www.iwebbasics.com

Feb 22, 2009 8:38 AM in response to Steve Mouzon

I found a decent way of adding Google Analytics to all pages, without using HTML Snippits (which cause analytics to track those odd page names like widget2_markup.html), that doesn't break MobileMe comments, and doesn't require any post-processing of your iWeb site. Just Publish and go! Open up your iWeb app bundle, and drill down to Contents/Resources/Scripts/Site. Open up the file iWebSite.js in TextEdit (or your favorite text editor), and paste the following at the bottom of the file:

// Begin Google Analytics
gaTrackerId = 'ss-ddddddd-d'; // insert your tracker id here

document.observe('dom:loaded', function() {
var gaJsHost = ( ('https:' == document.location.protocol) ? 'https://ssl.' : 'http://www.') + 'google-analytics.com/ga.js';
var script = new Element('script', { 'src': gaJsHost});
var gaTrack = function() {
if (
!script.readyState
|| /loaded|complete/.test(script.readyState)
) {
var pageTracker = gat.getTracker(gaTrackerId);
pageTracker._trackPageview();
}
};
script.observe('load', gaTrack);
script.observe('readystatechange', gaTrack);
document.body.appendChild(script);
});
// End Google Analytics

Credit to this solution goes to this blog post. I got the idea to find a way of using Google Analytics in Prototype (since iWeb sites use the Prototype JavaScript framework) and found that blog snippit.

And yes, since this is editing the iWeb application bundle, you may need to reapply this hack if/when iWeb is updated. Hopefully though, some enterprising iWeb engineer is reading this and will add proper Google Analytics support to iWeb for us. 🙂

Mar 2, 2009 9:05 PM in response to mr_proud

mr_proud wrote:
Actually I tried this in iWork 09, and it just won't work. As I try to output the site to a folder, it crashes before the process finishes with the spinning beach ball. If I look into the output folder, I can see that it is stopping as it tries to copy the new iWebSite.js script...

Any ideas?


I just tried replicating this with iWeb '09, but the test Sites I create publish successfully (with my modified iWebSite.js script. However, if you're publishing to a folder, you can't use MobileMe comments anyway, so this method/hack isn't necessary for you. You should be able to post-process the published files using something like iTweak to inject the Google Analytics code.

Apr 2, 2009 5:12 AM in response to Link Dupont

I have been having the same problem over the past 2 days. I was curious if anyone knew of a fix here.

I host through mobile me. When I publish to my site, it works. Then when I run the AddGoogleAnalytics Automator on my iDisk file iDisk/Web/Sites folder it runs and then when I go back to my site, the comments were taken off.

As stated, this has only been a problem for a few days and was working until last week. Additionally, I was getting stats on GA through the 29th and then it just stopped.

The site is www.givingitstraight.com

Right now I am starting the blog and for readership I have decided to keep the comments on the site over the tracking so GA is currently not installed on the site.

Thoughts?

Thanks!

Apr 17, 2009 7:42 AM in response to Link Dupont

@Link Dupont: Tried this with iWeb 09 and it didn't work. I tried two ways. I made a slight mod to an existing blog entry and I created a new blog entry. Neither page had the GA code appended.

Thanks though.

Michael

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Google Analytics breaks iWeb blog comments

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.