25
July 2005
Fusebox plugin for log based stats programs
[Coldfusion] [Fusebox]
Post a Comment
So I was reading on Pete Freitag's blog about the most common screen resolutions...
It got me interested in what my websites were being viewed at. Come to find out my hosting provider's new stats engine does not support this natively. I think quite a few Coldfusion people use HostMySite which recently dropped using Deep Metrixs and went to SmarterStats, so I hope this plugin will be useful to others.
First thing, the plugin could be integrated directly into the layout file but I decided to use a plugin instead. I put this into the PreProcess stage. The javascript came from a few places on the internet.
Then I <cfoutput>ed #request.clientstats# in the body section on my layout files.
In order to not generate a bunch of 404 errors in the server logs, I also created empty htm files for clientresolution.htm,clientviewableres.htm and fusebox.htm.
Now in SmarterStats I can run a custom report on querystrings for the files above that show client resolutions and the original fuseaction that is called per view (useful if any/all of your fuseactions are not URL submitted).
Oh and so far the results on my main website show only 16% of the requests coming in use 800x600 or lower.
It got me interested in what my websites were being viewed at. Come to find out my hosting provider's new stats engine does not support this natively. I think quite a few Coldfusion people use HostMySite which recently dropped using Deep Metrixs and went to SmarterStats, so I hope this plugin will be useful to others.
First thing, the plugin could be integrated directly into the layout file but I decided to use a plugin instead. I put this into the PreProcess stage. The javascript came from a few places on the internet.
<cfsavecontent variable="request.clientstats">
<script>
var screenW = 640, screenH = 480;
if (parseInt(navigator.appVersion)>3) {
screenW = screen.width;
screenH = screen.height;
}
else if (navigator.appName == "Netscape"
&& parseInt(navigator.appVersion)==3
&& navigator.javaEnabled()
)
{
var jToolkit = java.awt.Toolkit.getDefaultToolkit();
var jScreenSize = jToolkit.getScreenSize();
screenW = jScreenSize.width;
screenH = jScreenSize.height;
}
var innerwidth= 640, innerheight= 480; // defaults
if (self.innerHeight)
// all except Explorer
{
innerwidth= self.innerWidth;
innerheight= self.innerHeight;
}
else if (document.documentElement && document.documentElement.clientHeight)
// Explorer 6 Strict Mode
{
innerwidth= document.documentElement.clientWidth;
innerheight= document.documentElement.clientHeight;
}
else if (document.body)
// other Explorers
{
innerwidth= document.body.clientWidth;
innerheight= document.body.clientHeight;
}
<cfoutput>
document.write('<img src="clientresolution.htm?resolution=' + screenW + 'x' + screenH + '" height="1" width="1" />');
document.write('<img src="fusebox.htm?fuseaction=#myfusebox.originalcircuit#.#myfusebox.originalfuseaction#" height="1" width="1" />');
document.write('<img src="clientviewableres.htm?resolution=' + innerwidth + 'x' + innerheight + '" height="1" width="1" />');
</cfoutput>
</script>
</cfsavecontent>
<script>
var screenW = 640, screenH = 480;
if (parseInt(navigator.appVersion)>3) {
screenW = screen.width;
screenH = screen.height;
}
else if (navigator.appName == "Netscape"
&& parseInt(navigator.appVersion)==3
&& navigator.javaEnabled()
)
{
var jToolkit = java.awt.Toolkit.getDefaultToolkit();
var jScreenSize = jToolkit.getScreenSize();
screenW = jScreenSize.width;
screenH = jScreenSize.height;
}
var innerwidth= 640, innerheight= 480; // defaults
if (self.innerHeight)
// all except Explorer
{
innerwidth= self.innerWidth;
innerheight= self.innerHeight;
}
else if (document.documentElement && document.documentElement.clientHeight)
// Explorer 6 Strict Mode
{
innerwidth= document.documentElement.clientWidth;
innerheight= document.documentElement.clientHeight;
}
else if (document.body)
// other Explorers
{
innerwidth= document.body.clientWidth;
innerheight= document.body.clientHeight;
}
<cfoutput>
document.write('<img src="clientresolution.htm?resolution=' + screenW + 'x' + screenH + '" height="1" width="1" />');
document.write('<img src="fusebox.htm?fuseaction=#myfusebox.originalcircuit#.#myfusebox.originalfuseaction#" height="1" width="1" />');
document.write('<img src="clientviewableres.htm?resolution=' + innerwidth + 'x' + innerheight + '" height="1" width="1" />');
</cfoutput>
</script>
</cfsavecontent>
Then I <cfoutput>ed #request.clientstats# in the body section on my layout files.
In order to not generate a bunch of 404 errors in the server logs, I also created empty htm files for clientresolution.htm,clientviewableres.htm and fusebox.htm.
Now in SmarterStats I can run a custom report on querystrings for the files above that show client resolutions and the original fuseaction that is called per view (useful if any/all of your fuseactions are not URL submitted).
Oh and so far the results on my main website show only 16% of the requests coming in use 800x600 or lower.
Posted by fwscott at 5:46 PM | Comments (0)
Subscription Options
You are not logged in, so your subscription status for this entry is unknown. You can login or register here.
No comments found.