OneStat

Free customer support included.

We provide free customer support and will try to answer your questions to the best of our ability.

C. Script implementation


To start the measurements you have to implement a small piece of javascript in each HTML page you want to measure. If you are using frames, you have to implement the script in the content frame. The OneStat script can be implemented in several ways. You can implement the script with the OneStat script manager, paste the script in every page or generate the script from a server side scripting language. In this online manual we describe the different possibilities. OneStat measures URLs and Titles.

Implementing the OneStat generic script
In what situations should the OneStat script be modified?
How does the OneStat script determine the page-URL or title?
The OneStat script manager
Instructions for specifying and overruling the OneStat document name (URL)
Measuring directories
How to generate the default OneStat script from a server-side scripting language
Difficulties with editors like Frontpage and Dreamweaver

Script implementation - Implementing the OneStat generic script

The easiest way to activate your OneStat account is to put the OneStat generic tracking script in every html page of your website. You have received the script as attachment of your application e-mail. If you do not have this go to the settings manager and select "get script" to retrieve the latest version of the script. This is the standard generic script which you have to implement and you can put this script unmodified on every page of your website. Note: this script has no name. Use this script if you want OneStat to use the URL and Title of your HTML pages. Automatically the page-url including the parameters and the associated page title are being used to register the HTML page in OneStat. By viewing the report "Most visited pages" you can exactly see the different pages that are being measured.

Include the generic script in every page of your website. In the file where you saved it, highlight the tracking code. On your keyboard, press Ctrl-c to copy the code. Open each of your web pages and Press Ctrl-v to paste the code after the < body> tag and before the < /body> tag in the HTML pages. The best place to put the script is just before the < /body> tag. Upload your pages to your web server. Note: Some HTML editors such as Frontpage and Dreamweaver reformat code, and they can break JavaScript. Therefore we advise you to use Notepad, available for free in each Windows version (all programs, accessories).

Script implementation - In what situations should the OneStat script be modified?

In some situations the generic OneStat script is not appropriate to measure your site and you want to have more control over the exact urls that are being tracked. The following list gives some examples when to modify the OneStat script.

1. When using a content manager system or a database generated website that uses the same URL to publish different web pages with different content and the pages can not be uniquely identified by the url-parameters. In this situation all the statistics will be measured on the same page-url and it is not possible to analyze the behavior and navigation of the website visitors

2. When using a content manager that generates cryptic and difficult to analyze pageurls. In this situation the database driven website or content manager generates cryptic and difficult page-urls to analyze. By modifying the page-urls to logical urls it is much easier to analyze the website with OneStat.com.

3. When the urls of your website contain a unique session id. In this situation all the pages that are being measured are unique for each visitor. You are not able to analyze the overall navigation trends of your visitors. By modifying the page-urls to logical urls it is much easier to analyze the website with OneStat.com.

4. When using multiple domain-names for the same information. In this situation you are using multiple domain-names to present the same information and you want to analyze the website visitors with one account and add up the visits on the various domains.

Script implementation - How does the OneStat script determine the page-URL or title?

On lines 13 and 14 of the script (counting from the first line), the following javascript occurs: var osp_URL= d.URL; var osp_Title= d.title; The javascript function d.URL retrieves the page url, i.e. 'http://www.onestatdemo.com/home.html'. The javascript function d.title retrieves the title of the page i.e. 'Onestat Demonstration'.

Script implementation - The OneStat script manager

With the OneStat Script Manager you have more control of the urls that are being tracked. The script manager gives each page its own page-url and page-title. If you have for example a lot of "other" pages in the report "Most visited pages", you can use the script manager and overrule the script. You can find the script manager in the settings manager. If you have clicked on the tool icon you will enter the settings manager. Then you have to choose the script manager. Just do the following:

1. Select add custom page;
2. Fill in the page URL for example http://www.onestat.com/manual.html. If you are using directories you have to fill in this directory. For example http://www.onestat.com /product/manual.html. Directories are only tracked with the Platinum and Enterprise version.
3. Give the page a name. You will see this name appear in the reports of OneStat service.
4. If you don't use directories but you want to see which section is most visited just fill in the name of the section that you want to appear.
5. Click ok and select the script with your mouse and click on copy.
6. Open the html page where you want to implement the script in and paste the script between body and body and save the page.
7. Click to continue if you want to create more OneStat scripts and continue with the same procedures as described above.
8. Upload your pages to your web server.

Script implementation - Instructions for specifying and overruling the OneStat document name (URL)

The OneStat.com java-script ('the script') measures all pageviews and visits of the visitors of the website. The default behavior of the script is to automatically determine the URL of the page that is activated by the website visitor. In this way it is possible to put the same script on every webpage of the website and the Onestat.com statistical engine processes these page-urls. For most webmasters this default behavior is convenient, however there are a few cases where the webmaster wants to control the page-urls himself. This article describes how to modify the default Onestat.com script in this situation.

To overrule the default behavior of OneStat.com you have to modify lines 13 and 14 of the script and determine the correct name of the URL yourself by assigning a page-url to the variable osp_URL and a title to the variable sp_Title. I.e.:

var osp_URL= "http://www.myowndomain/mypagename.html"; var osp_Title= "The latest news";

- Make sure that you enclose the page-url in double quotes.
- We advise you to start the URL with http:// although this is not necessary. Also notice that the page-url you assign to the osp_URL variable does not have to be an existing URL. It can be any URL you like.

If you overrule the page-url as described above, you have to modify the script and assign a different page-url for each page you want to measure. When you are using a server-side script technology (i.e. ASP, CGI, PHP, JSP or ColdFusion) you can automate this as described in section E. Select the section "Modify account options" in the settings manager if you want OneStat to show URLs or Titles in your reports.

Script implementation - Measuring directories

OneStat Platinum and Enterprise can present information on a directory basis. Directories are automatically determined based on the page-urls. In the following example 6 page-urls are measured:

http://www.onestatdemo.com/products/page1.html
http://www.onestatdemo.com/products/page2.html
http://www.onestatdemo.com/helpdesk/page3.html
http://www.onestatdemo.com/helpdesk/page4.html
http://www.onestatdemo.com/helpdesk/page5.html
http://www.mydemo.com/helpdesk/page6.html

The OneStat engine automatically assigns two directories to these urls: "products" and "helpdesk". Notice that the last two pages have the same directory name but another domain name. An unlimited number of directory levels are supported. I.e. the following page-url contains 3 directory levels.

http://www.onestatdemo.com/firstlevel/secondlevel/thirdlevel/page.html

By assigning your own page-urls, you can also assign your own directory names and fine-tune the measurement of your pages

Script implementation - How to generate the default OneStat script from a server-side scripting language?

In this section we describe an extension of the overruling method as described above in the situation that you are using a server-side scripting technology (i.e. ASP, CGI, PHP, JSP or ColdFusion). The following examples are using the Microsoft Active Server Pages. When you develop a server-side function to generate the OneStat.com script code it is possible to re-use that function on every page of your website and provide the page-url as a parameter. The page-url parameter can be provided by a database or content management system or an other method. The output of the function is the complete script as provided by OneStat.com but generated by the server-side scripting technology. In the example below the lines in BOLD are the Microsoft ASP statements.

<%
Sub WriteOneStatTag(strPagename)
Dim strURL
Dim strAccountID
strURL = "http://www.onestat.com/asp/" & strPagename
strAccountID = "155454"
%>

<!--ONESTAT SCRIPTCODE START-->
<SCRIPT LANGUAGE="JavaScript">
<!--
// Modification of this code is not allowed and will permanently disable your account!
// SiteName: www.onedemostat.com
// Copyright (C) 2002-2008 OneStat.com All Rights Reserved
function OneStat_Pageview()
{
var d=document;
var sid="<%=strAccountID%>";
var CONTENTSECTION="";
var CUSTOMDATA="";
<%if strPageName = "" then%>
var osp_URL= d.URL;
<%else%>
var osp_URL= "<%=sURL%>";
<%end if%>
var osp_Title= d.title;
var t=new Date();
var p="http"+(document.URL.indexOf('https:')==0?'s':'')+"://stat.onestat.com/stat.aspx?tagver=2&sid="+sid;
p+="&url="+escape(osp_URL);
p+="&ti="+escape(osp_Title);
p+="&section="+escape(CONTENTSECTION);
p+="&custom="+escape(CUSTOMDATA);
p+="&rf="+escape(parent==self?window.document.referrer:top.document.referrer);
p+="&tz="+escape(t.getTimezoneOffset());
p+="&ch="+escape(t.getHours());
p+="&js=1";
p+="&ul="+escape(navigator.appName=="Netscape"?navigator.language:navigator.userLanguage);
if(osp_URL!=d.URL) p+="&ol="+escape(d.URL);
if(typeof(screen)=="object"){
p+="&sr="+screen.width+"x"+screen.height;p+="&cd="+screen.colorDepth;
p+="&jo="+(navigator.javaEnabled()?"Yes":"No");
}
d.write('<img id="ONESTAT_TAG" border="0" width="1" height="1" src="'+p+'" >');
}
OneStat_Pageview();
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="http://www.onestat.com"><img border="0" width="1" height="1"
SRC="http://stat.onestat.com/stat.aspx?tagver=2&sid=<%=strAccountID%>&js=No&">
</A>
</NOSCRIPT>
<!--ONESTAT SCRIPTCODE END-->
<%
end sub
%>

Script implementation - Difficulties with editors like Frontpage and Dreamweaver

This implementation FAQ answers your questions when you have troubles with implementing the OneStat script and tells you what to do with different HTML editors.
It only describes the implementation of the script to track visitor behavior.

This implementation FAQ answers your questions when you have troubles with implementing the OneStat script and tells you what to do with different HTML editors. 

It only describes the implementation of the script to track visitor behavior.
                

  1. I am using Dreamweaver 2 but still have difficulties
  2. I am using Dreamweaver 3 but still have difficulties
  3. I am using Dreamweaver 4 but still have difficulties
  4. I am using Hotdog 5.5 but still have difficulties
  5. I am using HotMetal Pro but still have difficulties
  6. I am using Microsoft Frontpage but still have difficulties<
  7. I am using Microsoft Frontpage 2000 but still have difficulties
  8. I am using Net Object Fusion but still have difficulties
  9. I am using Netscape Composer but still have difficulties
  10. I am using frames and URL forwarding and get a JavaScript Error
  1. I am using Dreamweaver 2 but still have difficulties

If you are experiencing problems with your OneStat.com stats, it may be due to Dreamweaver restructuring the OneStat code. Please remove the existing OneStat code and follow the below steps.

  1. Open your page in Dreamweaver and click on the <HTML> tab.
  2. Scroll through and insert the OneStat code into the <HTML> window anywhere between the <body> and </body> tags.
  3. Close the <HTML> window and save the changes to your page as a .html document.
  1. I am using Dreamweaver 3 but still have difficulties

If you are experiencing problems inserting the OneStat.com code into your pages using Dreamweaver 3, follow these instructions.

  1. Open your web page in Dreamweaver 3.0.
  2. Select 'HTML source code' from the 'Window' pull-down menu.
  3. Make sure that any previous OneStat code has been eliminated from your source code.
  4. Copy and Paste to insert code anywhere between the <body> and </body> tags.
  5. Preview in Browser to make sure that the code is inserted properly.
  6. Save file.
  1. I am using Dreamweaver 4 but still have difficulties

Dreamweaver 4, when installed, will default to correcting placement and syntax of your HTML tags in your code (thus, altering the OneStat code as well). To prevent this, go to:

  1. EDIT --> PREFERENCES
  2. Click "Code Rewriting"
  3. UN-check both:
    • fix invalidly nested and unclosed tags
    • remove extra closing tags

The "warn when fixing or removing tags" box will automatically uncheck once the above two options are manually unchecked.
Once these steps are completed, you can cut and paste into the HTML code window:

  1. Click the "<>" button to go to code mode.
  2. OR, go VIEW --> CODE
  3. Make sure that any previous OneStat code has been eliminated from your source code.
  4. Copy and Paste to insert code anywhere between the <body> and </body> tags.
  5. Preview in Browser to make sure that the code is inserted properly.
  6. Save file.  
  1. I am using Hotdog 5.5 but still have difficulties

OneStat.com works correctly with the HotDog Professional 5.5 editor. If you have encountered errors, please follow the below steps.

  1. Insert original OneStat code between tags.
  2. Click on the External Preview in the "File" Toolbar or (F9) and select a browser to view the page in.
  1. I am using HotMetal Pro but still have difficulties

Paste the OneStat code anywhere between the <Body> and </Body> tags. Ignore any markup errors.

  1. I am using Microsoft Frontpage but still have difficulties

If you are experiencing problems with your stats, it's most likely due to FrontPage running together the OneStat code. Please delete the OneStat code out of your page and follow the below steps.

  1. View your page in "Normal".
  2. Place your cursor where you'd like to insert the OneStat code.
  3. Click on "Insert" from the dropdown menu.
  4. Click on "FrontPage Component."
  5. Click on "Insert HTML"
  6. Insert the OneStat code between the body tags:
  7. Click "Ok"
  1. I am using Microsoft Frontpage 2000 but still have difficulties

If you edit your pages with FrontPage 2000 and are experiencing problems with your stats, it's most likely due to FrontPage altering the OneStat code. Please delete the OneStat code out of your page and follow the steps below:

  1. View your page in Design View (default view).
  2. Click on bottom of page.
  3. Click Insert > Advanced and select "HTML".
  4. Place your cursor where you'd like to insert the OneStat code.
  5. Insert the OneStat code between the body tags.
  6. Click "Ok"
  1. I am using Net Object Fusion but still have difficulties

If you are experiencing trouble installing your OneStat code using NetObjects Fusion 5.0, please follow the instructions below.

  1. Open page in NetObjects Fusion 5.0.
  2. Click the 'HTML Source' tab.
  3. Paste the OneStat code between the <body> and </body> tags.
  4. Click on 'Page Preview' tab.
  5. Save page.
  6. You may then examine the location of OneStat in Page Preview mode.

Note: If you wish to change the location of your OneStat, return to HTML Source, delete existing OneStat code, and try inserting the code in a different location within the HTML.

  1. I am using Netscape Composer but still have difficulties

This may be related to the way certain Netscape Composer rewrites our JavaScript code into their own version, and not a problem with our code. Here are some steps to make it work with composer.
To setup OneStat with Netscape Composer.

  • Open up your composer window.
  • Go to the preferences tab and select composer.
  • Go to the box External Editors.
  • Under HTML Source please select an editor.
  • Click on the choose button and go to your directory
  • Find either notepad.exe (Windows), or SimpleText (Macintosh) file.
  • Highlight the application and click open.
  • This selects notepad or SimpleText as your default editor. Click Ok.
  • You are now ready to edit the source code and paste the OneStat code to your page.

You can also insert our code using a text editor such as Notepad or SimpleText, or use the HTML translation abilities in many word processors.

  1. I am using Frames and URL forwarding and get a JavaScript Error

Replace in the OneStat script the following line:
   p+="&rf="+escape(parent==self?window.document.referrer:top.document.referrer);
By:
   p+="&rf="+escape(document.referrer);