PDA

View Full Version : creating an individual hit counter ASP


UKSBD
3rd August 2009, 22:30
Working in ASP

In my directory the same file,
business-listings.asp
creates thousands of individual pages
i.e.
http://www.uksmallbusinessdirectory.co.uk/business-listings.asp?strCompanyName=Genesis

http://www.uksmallbusinessdirectory.co.uk/business-listings.asp?strCompanyName=londonwindows

etc.

Is there a way to create a counter that counts individual page hits
despite the fact it is the same file that creates the page?

i.e.
I know how often an indivdual page is visited, rather than just the file.

googol
3rd August 2009, 23:08
Google Analytics can track such things (I have a client with a similar setup in their CMS using Google Analytics).
The other alternative would be to read the page requested in the querystring and track that (presumably similar to the method used to identify the page requested and load the relevant content from the database/text file)

UKSBD
3rd August 2009, 23:52
yes, google analytics does this, but like I say, there are thousands of
pages and I don't particularly wan't to have to log in to analytics, then
go looking for stats on an individual page.

Ideally I just want something that works like statcounter but just shows
how many times a page has been viewed.

woodss
4th August 2009, 00:25
This is dead simple

Get the current page info in ASP with:

<%
strPageName = Request.ServerVariables("SCRIPT_NAME")
strParams = Request.QueryString()
%>

Then record it in a database. Then all you'd have to do is bring it back out of the database in your backend system using a simple query.

I can do this for you no problem at all - PM me if you want :)

UKSBD
4th August 2009, 10:08
Google Analytics can track such things (I have a client with a similar setup in their CMS using Google Analytics).



I just tried analytics again, it's great using the Top content > content
performance and then using the search (it revealed some peoples
individual listings received over 1000 views in July) Too time consuming
really though for what I want.

Kev Jaques
4th August 2009, 10:28
Would have thought you'd have this built in from the start really for this kind of site.
GA is also good for depth of visit, reveals people are totally lazy unless they really really want to dig into your content.
Therefore the most important levels are only 1 level deep

I would hold a glue table linked with the company name/id with a hitcount and update it when that company name/id is hit, as woodss said then it's easy to retrieve top performers or hit counts based on company names/ids

UKSBD
4th August 2009, 11:00
You guys do have a habbit of making things sound easy :)

I'm just self taught, learn as I go along , and add more features as I learn more :redface:

I presume I add another column to my company table which updates the
hit count? no idea how it updates though :mad:

Kev Jaques
4th August 2009, 11:15
Without looking how your existing pages are created codewise, you should analyse your tables.
I would possibly leave your company table alone (less schema changes the better) and create a new glue table, if you use the company id column then use that as the glue ids(not primary) (or name if using name (not recommended but better than nothing))
This new table can be updated on its own prior to when you retrieve the page for x company with for example update newhitcounttable set hitcount = hitcount + 1 where companyid = xxx.
You would also need to update this new table on insert/delete of your company table to insert/delete(flag as deleted better) a new company record

TheAlbear
4th August 2009, 11:23
Google anlytics allows you to create a custom report. which can then be pulled up with a single click, I would go down that route..

matt.chatterley
4th August 2009, 11:41
Google anlytics allows you to create a custom report. which can then be pulled up with a single click, I would go down that route..

Although GA is excellent, I would be tempted to build something into the site to handle this as well - then you have the basic data immediately available, definitely correct (according to your own rules), and so forth - without relyin gon a third party.

Then you can ALSO use GA and pull extra stats out. Happy days. :)

woodss
4th August 2009, 13:52
I've built you something FoC :)

See your PMs and if you need any help setting it up give me a shout.

UKSBD
4th August 2009, 18:28
Massive thanks to woodss for setting this up for me and also helping
with the tinkering to get it working well.

Kev Jaques
4th August 2009, 18:35
You might want to make it a bit more robust, check http://www.uksmallbusinessdirectory.co.uk/county_details.asp or any non standard strings and return a default page instead of the rs errors

ADODB.Field error '800a0bcd'
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
/county_details.asp, line 347

also at
ADODB.Field error '800a0bcd'
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
/cat_count.asp, line 468

and
/counties-cats.asp, line 185

woodss
4th August 2009, 18:45
That's nothing to do with what has been added today...

Kev Jaques
4th August 2009, 18:48
I didn't say it was ;)... but still valid nonetheless ;)

woodss
4th August 2009, 18:59
Baby steps - i'm sure he'll iron out any kinks as time goes on :)

UKSBD
4th August 2009, 19:25
You might want to make it a bit more robust, check http://www.uksmallbusinessdirectory.co.uk/county_details.asp or any non standard strings and return a default page instead of the rs errors

ADODB.Field error '800a0bcd'
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
/county_details.asp, line 347

also at
ADODB.Field error '800a0bcd'
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
/cat_count.asp, line 468

and
/counties-cats.asp, line 185


Thanks,
I do it on the individual pages,
http://www.uksmallbusinessdirectory.co.uk/business-listings.asp?strCompanyName=none-here

just haven't got around to doing it to those pages yet.

Kev Jaques
4th August 2009, 19:29
nps :)
Hmm, how come you're not using a set of functions in an xt page for record retrieval? Then you wouldn't need to do it on every page, you only need a disconnected record set which is already taken care of.

UKSBD
4th August 2009, 19:55
When I said pages I should really have said files, there was only reallly 5
or 6 files needing editing to go to an error page.
Main reason for doing it separetly is because I am sending different files
to different error pages.