Examples
Simple Example
<html>
<head>
<script type="text/javascript">var _sf_startpt=(new Date()).getTime()</script>
<title>Hello World</title>
</head>
<body>
<h1>Hello World</h1>
<div>
Welcome to the most fabulous home page.
</div>
<script type="text/javascript">
var _sf_async_config={};
/** CONFIGURATION START **/
_sf_async_config.uid = 1234; /** CHANGE THIS **/
_sf_async_config.domain = "changeme.com"; /** CHANGE THIS **/
/** CONFIGURATION END **/
(function(){
function loadChartbeat() {
window._sf_endpt=(new Date()).getTime();
var e = document.createElement("script");
e.setAttribute("language", "javascript");
e.setAttribute("type", "text/javascript");
e.setAttribute("src",
(("https:" == document.location.protocol) ?
"https://a248.e.akamai.net/chartbeat.download.akamai.com/102508/" :
"http://static.chartbeat.com/") +
"js/chartbeat.js");
document.body.appendChild(e);
}
var oldonload = window.onload;
window.onload = (typeof window.onload != "function") ?
loadChartbeat : function() { oldonload(); loadChartbeat(); };
})();
</script>
</body>
</html>
Overriding Title and Path With PHP
This example shows how to override the title and path for a
page. We assume that the CMS generating the page uses PHP, and the
clean path is in the variable '$page_path' and the
title in '$page_raw_title'.
<html>
<head>
<script type="text/javascript">var _sf_startpt=(new Date()).getTime()</script>
<title>Springfield Times: Krusty the Clown Show, with Princess Penelope</title>
</head>
<body>
<h1>Krusty the Clown Show, with Princess Penelope</h1>
<div>
Beware citizens of Springfield, this Tuesday The Krusty the Clown
Show will feature a new co-host: Princess Penelope!
</div>
<script type="text/javascript">
var _sf_async_config={};
/** CONFIGURATION START **/
_sf_async_config.uid = 1234; /** CHANGE THIS **/
_sf_async_config.domain = "changeme.com"; /** CHANGE THIS **/
_sf_async_config.path = "<?php echo $page_path; ?>";
_sf_async_config.title = "<?php echo $page_raw_title; ?>";
/** CONFIGURATION END **/
(function(){
function loadChartbeat() {
window._sf_endpt=(new Date()).getTime();
var e = document.createElement("script");
e.setAttribute("language", "javascript");
e.setAttribute("type", "text/javascript");
e.setAttribute("src",
(("https:" == document.location.protocol) ?
"https://a248.e.akamai.net/chartbeat.download.akamai.com/102508/" :
"http://static.chartbeat.com/") +
"js/chartbeat.js");
document.body.appendChild(e);
}
var oldonload = window.onload;
window.onload = (typeof window.onload != "function") ?
loadChartbeat : function() { oldonload(); loadChartbeat(); };
})();
</script>
</body>
</html>