how do external counter track unique visitors via image
i’d also like to get Referrer if possible.
something like img=”http://www.somecounterdomain.com/count.php?page=83599″
i’m using ASP.NET, c#
i’m aware of a user can “cheat” but would like to make that posibility minimal.
additional difficulty is that i should trach external server and can’t implement c# code there.
what i can is only imlement a counter imag or smth like that.
i try to use generated image.
thx for answers.
how do external counter track unique visitors via image i’d also like to get
Share
Basically what you need to do is the following.
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.
private void Page_Load(object sender, EventArgs e) { WriteQueryStringInformationToDB(Request.QueryString);}
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… :))
function mystats(id) { // Base URL including the ID of the counter var url="http://yourdomainorservername/statserver.aspx?id="+id;}
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.