Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Basically what you need to do is the following.</p> <p>1- Create either a .ashx or .aspx. Assuming you go with .aspx and call it StatServer.aspx, the Page_Load function will read the query string and write the data to a database, you will see the querystring in step 2. If you want, you can return a image which can be rendered. Some rough code will look something like this.</p> <p><code><pre> private void Page_Load(object sender, EventArgs e) { WriteQueryStringInformationToDB(Request.QueryString);</p> <pre><code>Image image = LoadYourImageHere(); using (MemoryStream stream = new MemoryStream()) { base.Response.Clear(); base.Response.ContentType = "image/png"; image.Save(stream, ImageFormat.Png); stream.WriteTo(base.Response.OutputStream); base.Response.End(); } </code></pre> <p>} </pre></code></p> <p>2- This is the magic, you create a small .js file. In this file you have a function lets call it mystats() which will essentially gather the client side information and make a call to the URL hosting the page you created in step 1. The client side information like screen size, referer etc. is all passed on the querystring. One important thing to include in the function is an ID which indicates which which counter you are updating, that way you can use your counter on multiple sites. A very simple .js might look something like this. (Note tested etc... :))</p> <p><code><pre> function mystats(id) { // Base URL including the ID of the counter var url="http://yourdomainorservername/statserver.aspx?id="+id;</p> <pre><code>// Add the referer to the url querystring url += "&amp;r=" + escape(document.referrer); // Add screen width + height url += "&amp;w=" + screen.width + "&amp;h=" + screen.height; document.write('&lt;img src="'+url+'" border=0 alt="Site statistics"&gt;'); </code></pre> <p>} </pre></code></p> <p>3- On the web pages that you want to apply the counter, you add a script block that includes the the .js file from your server and calls the mystats function from an img tag, this causes the js code to collect the info and send a request to your server, which in turn updates the DB and returns the image stream to display.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload