Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Feb 2006
    Posts
    62
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Tracking Web Page Views

    I have a web page that I want to track by adding this link in the page's HTML code

    Code:
    <img src="track-me.asp?tc=824201224729">
    On the page track-me.asp, which has code to count the visits to the page based on the tc variable and store the count in a database, how do I retrieve the tc code number? I've tried Request.Querystring("tc"), but it doesn't work
    I know about Google Analytics and other tracking applications, but this is a special project where I give the tracking code link to someone and they place it on their web page

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,202
    Thanks
    80
    Thanked 4,453 Times in 4,418 Posts
    Request.QueryString("tc") *SHOULD* work.

    If it doesn't then you have some weird problem.

    You can possibly debug it this way (put this code at the *START* of your track-me.asp page):
    Code:
    <%
    Response.Write "Full query string is ::" & Request.QueryString & "::<hr/>"
    For Each n In Request.QueryString
        Response.Write "Request(" & n & ") is ::" & Request.QueryString(n) & "::<br/>"
    Next
    Response.Write "<hr/>" & vbNewLine
    %>
    What does that show you?

    Oh...and to test this, just hit your "track-me.asp" page directly, typing it into your browser's URL bar. *NOT* are part of the page with the <img> tag.

    Here's a question for you: Is the web page with that <img> tag coming from the SAME BASE URL as the "track-me.asp" is?

    For example, say that the main page is http://www.yoursite.com/portfolio/page1.html. But say your tracker is http://www.yoursite.com/track-me.asp OOPS! Big goof! If you only use <img src="track-me.asp"> then the browser will be looking for the FULL url of http://www.yoursite.com/portfolio/track-me.asp

    Generally, the best thing for a tracker like this is to put the full URL (yes, including the http://) into the <img> tag.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    New Coder
    Join Date
    Feb 2006
    Posts
    62
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Nope, doesn't work.

    On website1 I have track-me.asp with your debug code right at the top. If I hit this page directly, it works.

    On website2 I have a blank HTML page with this code on it:

    Code:
    <img src="http://www.website1.com/track-me.asp?tc=825201294728">
    What I'm trying to do is emulate http://monitorhits.com
    Last edited by SteveSensei; 08-25-2012 at 09:22 PM.

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,202
    Thanks
    80
    Thanked 4,453 Times in 4,418 Posts
    Got me. Haven't a clue why it doesn't work.

    Tell you what. Try this *temporarily*:

    On website 2, create an HTML (or ASP) page that has this:
    Code:
    <a href="http://www.website1.com/track-me.asp?tc=825201294728" target="_blank">
    Test it out
    </a>
    Bring up the page and click on the link. It should pop up a new window (make sure you aren't blocking popups completely) with the results of track-me.asp.

    If it does, and if the <img> trick doesn't work, then can you show a public link to the <img> page?

    OH!!! I just throught of one thing! *IF* you have <img style="display: none;"> or even <div style="display: none;"><img ... /></div> then the browser *COULD* decide to not even bother trying to load the image. I'm pretty sure this is true with MSIE, for example. There's an easy solution, if this is the problem:
    Code:
    <img style="height: 1px; width: 1px; display: inline; visibility: hidden;"
          src="http://www.website1.com/track-me.asp?tc=825201294728" />
    So now it creates a 1x1 pixel image but then makes the image HIDDEN, which is not the same as not displayed, and the browser *will* go fetch the file.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •