Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Modify iWeb sites to work with Google Analytics Apps
Not really being able to properly use Google Analytics together with iWeb has been bothering me for a while. I've been checking the source iWeb output, and came up with a rather simple, semi-automatic (lacking some AppleScript skills to make it fully automatic) solution using BBedit. (This should also work with any other text editor that supports multi-file search and replace.)

Using BBEdit's Search function, I made a multi-file search through all of the iWeb project's .html files, searching for...
</body>
...and telling BBedit to replace it with this:
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "##-######-#";
urchinTracker();
</script>
</body>
Replace the ##-######-# with your site's tracking ID. Now just save this as a search pattern, and every time after publishing your site to a folder (~/Sites in my case), just apply it to that folder.

Using AppleScript, it should even be possible to make this a more or less automatic task. It's not very sophisticated, but for my needs it does the job well. It even works if you are publishing to your .Mac account -- simply apply the rules on your specific iDisk's iWeb Folders. (For reference, this hint comes from this entry on my blog.)
    •    
  • Currently 1.75 / 5
  You rated: 2 / 5 (4 votes cast)
 
[27,969 views]  

Modify iWeb sites to work with Google Analytics | 4 comments | Create New Account
Click here to return to the 'Modify iWeb sites to work with Google Analytics' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Modify iWeb sites to work with Google Analytics
Authored by: gert on Dec 22, '06 08:04:46AM

maybe the following site is worth looking at if you're interested in implementing Google Analytics.

http://rsvp-xnews.blogspot.com/2006/10/shell-vs-applescript-1-0.html[link:]

The author of this sites uses a unix script to do what you want.



[ Reply to This | # ]
Modify iWeb sites to work with Google Analytics
Authored by: jecwobble on Dec 22, '06 09:47:57AM
I don't use iWeb so I don't know how it may or may not overwrite existing/unchanged files, but I would be careful not to replace
</body>
tags in files that have already had this find-n-replace applied, or you will be the additional script tags multiple times.

[ Reply to This | # ]
Modify iWeb sites to work with Google Analytics
Authored by: mooman on Dec 23, '06 06:24:30AM

Every time you publish to a folder in iWeb it completely rewrites everything, including HTML, images and whatever there is to be published, so if you make sure that you don't do the search and replace twice after exporting you should be fine.

Of course it never hurts to verify that nothing went wrong once in a while, especially should apple dash out an update to iWeb.



[ Reply to This | # ]
Modify iWeb sites to work with Google Analytics
Authored by: nickv2002 on Dec 23, '07 05:01:18PM

There is already a nice Automator Action that takes care of this for you using an integrated shell script. It seems to work pretty well in my limited use: Add Google Analytics Action

Just pass it your sites folder (or wherever you published) and it will make the necessary changes. I've integrated into an Automator workflow that takes care of all the publishing for me as well (via a Transmit). It seems to work with both iWeb '06 and iWeb '08 sites too.



[ Reply to This | # ]