Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Most Popular Articles - determined by link hits

Status
Not open for further replies.

crystalb24

Programmer
Aug 31, 2004
75
US
I've been given a project at work that I'm hoping someone can help me with.

Our marketing department want to create a section on there internal homepage to feature 5 articles a day, track the most popular articles by how many people use the links provided to the full text of the article, and then populate a box of the top 5 most popular articles. They want to do this with as much automation as possible, very little human interaction.

Here is the code for the stories piece:

Code:
            <td><p class="style11"><a href="main.html#top"><img src="images/logo.jpg" width="511" height="44" border="0"></a><br>
              <span class="style18"><a href="main.html#1">Weekly WYSdom: The Excellent Day</a></span><br>
        How to make the most of each business day from FA, Bill Smith.<br>
        <span class="style18"><a href="main.html#2">Six Steps to a Secure Retirement Seminar</a></span><br>
        New Envision seminar for retirees and preretirees now available.<br>
        <span class="style18"><a href="main.html#3">Roth Conversion Opportunity</a></span><br>
        Traditional IRA account holders over age 701/2 also have an expanded opportunity to reposition their taxable retirement savings to a tax-free Roth IRA under new regulations<br>
        <span class="style18"><a href="main.html#4">Consulting for Foundations: How to Get Started</a></span><br>
        Sensible advice on asset allocation can help a private foundation steer clear of tax laws and better pursue its charitable mission&mdash;and get you tapped into a lucrative investment consulting niche. <br>
        <span class="style18"><a href="main.html#5">DMA Success Story</a></span><br>
        Whayne Porter recounts how DMA helped him win a major new client.</p>
            </td>

Is there a way to track the link hits and create a list of the most popular articles (possibly using refresh pages to track??), or is this just something that is going to have to be managed by a web coordinator?
~Crystal


~Crystal
 
All of your links look like they just go to numbered anchor positions on the main.html web page.

This means that the link is a function of the browser rather than the server. The web server is going to send the entire page to the client machine whether they read all of the stories or none of them.

If you want to track these things from the server, the best way is to move the articles onto separate pages and then count the hits for each page.

 
If you must do it from the client side then perhaps you could make a little JavaScript function that fires when the link is clicked... the purpose of the function would be to use the xmlhttp object thingy to send a request back to the web server to increment a tracking counter of some sort... the web page called by the xml object wouldn't really be a web page in the sense that it has no real user interface... it just counts the requests from each link.

But really, if you put them all on the same page, this is a terrible way of figuring out which is most popular. If I click the link for #3 and read the first half of it and then decide it stinks and kinda then skim the rest of it and continue to #4... then #4 gets no credit even if I enjoyed it more and read it all the way thru.
 
And if someone has ActiveX disabled, the "xmlhttp object thingy" might not work because it's instantiated from an ActiveX control.

Lee
 
crystal,

it's assumed you have access to the web server and have asp since you posted in this forum; therefre, why not use a database to track the hits and have an admin page to update links. i did not write an admin page but here's some code to try to get you started on how to display by popularity. Also I didn't include your bookmarks since i don't have the main.asp code but simply add &#1 at the end of the link

Good Luck!

Brian

test script here:

link_tracker.asp
Code:
<html>
 <head>
   </head>
 <body>  

<td>
  <p class="style11">
   <a href="linkcounter.asp?&#top"><img src="images/logo.jpg" width="511" height="44" border="0"></a><br>
    <span class="style18"><a href="linkcounter.asp?link=1&#1">Weekly WYSdom: The Excellent Day</a></span><br>
     How to make the most of each business day from FA, Bill Smith.<br>
     <span class="style18"><a href="linkcounter.asp?link=2&#2">Six Steps to a Secure Retirement Seminar</a></span><br>
     New Envision seminar for retirees and preretirees now available.<br>
     <span class="style18"><a href="linkcounter.asp?link=3&#3">Roth Conversion Opportunity</a></span><br>
     Traditional IRA account holders over age 701/2 also have an expanded opportunity to reposition their taxable retirement savings to a tax-free Roth IRA under new regulations<br>
     <span class="style18"><a href="linkcounter.asp?link=4&#4">Consulting for Foundations: How to Get Started</a></span><br>
     Sensible advice on asset allocation can help a private foundation steer clear of tax laws and better pursue its charitable mission&mdash;and get you tapped into a lucrative investment consulting niche. <br>
     <span class="style18"><a href="linkcounter.asp?link=5&#5">DMA Success Story</a></span><br>
     Whayne Porter recounts how DMA helped him win a major new client.</p>
    </td>

</body>
</html>

linkcounter.asp

Code:
<%

  link = Request("link")
  
Set objConn = Server.CreateObject("ADODB.Connection")
Set objRS = Server.CreateObject("ADODB.Recordset")
FilePath = Server.MapPath("db/link_tracker.mdb") 
objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & FilePath & ";"

strSQL="SELECT LinkID,Hits FROM tblLinks WHERE LinkID=" & link & ";"
objRS.Open strSQL, objConn, 3 ,3

If isNull(objRS("Hits")) OR objRS("Hits") = 0 Then

objRS("Hits") =  1
Else

objRS("Hits") = objRS("Hits") + 1

End If
objRS.Update

response.write objRS("Hits")
objRS.Close

response.redirect "main.asp"
%>

main.asp

Code:
<html>
 <head>
   </head>
 <body> 
 
<h2>Top 5 most popular articles</h2>
<hr>

<%  
  Set objConn = Server.CreateObject("ADODB.Connection")
  Set objRS = Server.CreateObject("ADODB.Recordset")
  FilePath = Server.MapPath("db/link_tracker.mdb") 
  objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & FilePath & ";"

  strSQL="SELECT Link, Hits FROM tblLinks WHERE Hits <> 0 ORDER BY Hits DESC;"
  objRS.Open strSQL, objConn

  
  Do While Not objRS.EOF

  i = i + 1
  response.write i & ". <a href=""link_tracker.asp"">" & objRS("Link") & "</a>---- Viewed " & objRS("Hits") & " times<br>"

  

  objRS.MoveNext
  Loop
  objRS.Close
%>

</body>
</html>
 
xmlhttp object thingy"

Ah cut me some slack... I'm trying to quit smoking and my mind is less than clear!
 
Brian,

I'm still fairly new with working with asp so forgive me if these are stupid questions, but I want to make sure I understand this before I give it to them to use.

The link_tracker.asp page would be the page that is visible on the client side, the linkcounter.asp page would handle the tracking of each link and the main.asp page would be the visible list of the most popular articles - correct?

And everyday when we update the daily articles we would do so on the link_tracker.asp page and the main.asp list of most popular links would be maintained?

I want to be able to hand this back to them requiring as little daily interaction as possible, and without them having to come back to me.

~Crystal
 
Unless I misunderstood your question, this code will not do what you want. This code is a survey where the user clicks the favorite link and then goes to a results page to that shows the status of the voting.

In the orignal posting, the HTML was structured such that clicking a link would take you to an anchor... I'm assuming that anchor would be at the top of the article.

Is really only a simple poll-type thing or are the links supposed to take you to the article?
 
It's sort of meant to do both. Here is a break-down of what I'm trying to accomplish:

Every day 5 new articles will be posted. As the clients click through to read the full articles (which are on a seperate page - all on one page preferably), these link hits are recorded. On a weekly basis, a table on the same page is updated with the previous weeks most popular articles based on the recorded hits for each link.

I'm trying to figure out a way to do this with minimal web-coordinator interaction as possible as I am not the coordinator for that department and the person who is would surely screw this up.


~Crystal
 
Will it ever be the case that the same article will appear in more than one day? Like for example today's #1 article is still on the list tomorrow, but it is #5 in tomorrow's list and the next day it falls off the list.


Are all 5 articles chosen at one time and all "appear" on the page at the same time, replacing the previous 5?


The reason I'm asking is that I'm trying to figure out if you need to have a unique "ID" for each article or is it enough to use the date and list position to identify any article.


Perhaps the best way to handle this would be to have an administrative page where the web-cordinator person chooses the 5 articles and then "publishes" them to the site. This would give you the opportunity to assign any required key on the back end and hopefully minimize their opportunity to screw it up.
 
Also I am glad to see that the articles are on a seperate page because this will give you the opportunity to count them on the server.

If the browser could complete the link request without a page transition then keeping tally is a much more difficult task.

Putting all 5 on one page, even if it is a different page, still presents the problem of finishing one article and then continuing on to the next without giving the 2nd article a vote. You should make them aware of this but I don't suppose you have any ethical obligation beyond raising the issue.
 
There wouldn't be any overlapping of the articles. Each day would be 5 brand new articles, although I imagine that there would be a link to view the previous how ever many days worth of articles as well.

And being as unfamiliar with asp as I am, how do I go about setting up an admin page, and the subsequent pages as well.

~Crystal
 
I can make several suggestions on this but I really want to understand a little better so that I don't suggest something that is overkill.

As it stands now, does this web-cordinator person create a plain HTML page using some WYSIWYG* editor like Front Page or MS Word?


* By WYSIWYG I mean "What You See Is What You Get" ... no knowledge of HTML required.

 
He does have a working knowledge of html, that's not really what I'm worried about. It's more about having it automated for the times when he is not in the office, or otherwise just too busy to get to it, it would still need to be updated on a regular basis (like first thing Monday morning). He also doesn't like the idea of this adding anything whatsoever to his work load. The less that he will have to do with this, the less of a headache for me it will be in the long run.

~Crystal
 
I uploaded a mockup of what I'm trying to accomplish, at least as far as I've gotten it so far which is basically just the html portion.

Everyday the "main.html" would be changed to show the 5 new articles. I'm imagining that we wouldn't be calling this page 'main', but rather naming it for the date of the articles. I think for tracking purposes that it would be better to have each article on an individual page and I can sell them on that.

The part of the table that has "Last weeks most popular links" is what they would like to have automatically populate, with the article title, description and link to that article.

Here is the mockup html page:


~Crystal
 
the main.asp could easily accomodate the actual article by adding article memo field to table...this demo was to demonstrate how to rank the links clicked the most....hence "most popular"...when the user clicks on the link it could go to the actual article using the uniqueid....yeah i could have done this but it was more to show how the tallying of hits was done to make most popular...instead of going straight to the article...instead of using a anchor the uniqueid in a sense is the anchor....no need to list ALL articles on one page when there are 5 linksfor a user to choose from and by clicking on it goes to that article...puts a hit in the database...gets ordered by popularity...and as i had said...i did not create an admin page and yes, it would certainly need one to maintain the links(TITLE) and actual articles w/ minimal effort by using a simple form to add data to the two fields...didn't know about the previous top 5...so a "timestamp" could inserted into another field...this code could easily be modified to do what you need for popularity but would need an article memo field(no big deal) and a timestamp for datediff and sorting by the hits during that interim...i guess in a sense it is a survey.....a survey to see what is the most popular article...this code can do that

Brian
 
here's an example of looking up articles with links....it was a simple script to help another in forum search articles...not what you want but to show there is no need to write out the articles on a full page and having to use anchor tags...yet you still could do so if needed

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top