SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Member
    Join Date
    Jul 2002
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cool Click through rate

    Is it possible to put different actions behind one hyperlink. For example when a hyperlink is selected a new web page is openend and an e-mail is send to a specified e-mail adress. If this is possible i could count how many times a hyperlink is clicked.

  2. #2
    SitePoint Evangelist
    Join Date
    Oct 2001
    Posts
    439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes this is possible......

    there are probably many types of link hit counters at hotscripts.com

  3. #3
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    .oO( Or you could write your own )

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  4. #4
    Grumpy Mole Man Skunk's Avatar
    Join Date
    Jan 2001
    Location
    Lawrence, Kansas
    Posts
    2,067
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You really, really don't want to do that with javascript - especially not the mail sending bit (a large number of surfers don't have their mail client set up to work with their browser, mostly because they use a webmail account instead). Here's a very short PHP script that demonstrates one way of achieving the effect you describe:
    Code:
    <?php
    $emailAddress = 'you@yourhost.com';
    $url = (isset($_GET['url'])) ? $_GET['url'] : false;
    if (!$url) {
      die('No URL specified');
    }
    mail($emailAddress, 'A link was clicked', "The link clicked was $url");
    header("Location: $url");
    ?>
    Save that as redirect.php (provided you have PHP hosting) and create links like this:
    Code:
    <a href="redirect.php?url=http://www.google.com/">Google</a>
    Every time the link is clicked on a mail will be sent to you telling you about it.

    That said, I would not recommend using this technique as it stands. Someone could click the link a few hundreds times and flood your inbox with spam. A much better solution would be to log every click of the link to a database (again using a server side language such as PHP) and create some kind of admin tool that lets you view the links in the database and how many times they have been clicked.

  5. #5
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I suppose we should really let them flaunt php wherever they can ... the poor souls!

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  6. #6
    Grumpy Mole Man Skunk's Avatar
    Join Date
    Jan 2001
    Location
    Lawrence, Kansas
    Posts
    2,067
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <quietly smiles at the amount of ASP code required to do the same thing>

  7. #7
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I hope that wasn't an insinuation i use asp

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  8. #8
    Grumpy Mole Man Skunk's Avatar
    Join Date
    Jan 2001
    Location
    Lawrence, Kansas
    Posts
    2,067
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I apologise completley - I just spotted your custom title

  9. #9
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    he he - that's ok - i don't think i could live without
    OO web programming

    .oO( not that anyone ELSE would use it )

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---


Bookmarks

Posting Permissions

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