SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast Mr Toner's Avatar
    Join Date
    Sep 2003
    Location
    Southern California, USA
    Posts
    78
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    SE-friendly link, with actual destination different

    I need to have certain links on my site appear to go one place for search engines:

    <a href="http://example.com" ...

    but go through an intermediate script to track clicks:

    ... onclick="window.location='http://example.org/track.php?id=112';">

    I suppose that's easy enough, but, if the user doesn't have Javascript enabled, I'd like the click to still go through the tracking script.

    Any suggestions?

  2. #2
    SitePoint Member
    Join Date
    May 2010
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I suppose that's easy enough, but, if the user doesn't have Javascript enabled, I'd like the click to still go through the tracking script.
    According to this, it doesn't seem like Javascript is what you should go for in the first place. By posting that here, you're kinda saying "I want to use Javascript for this, but i need it to work without Javascript."

    Is there a way you could just
    Code:
    <?php require('track.php'); ?>
    from your header in all your webpages and just pass a superglobal to it with your href? Or is that not at all how your tracking script works?

    I guess I would need to know how your tracking script works to get an idea of how to approach this.

  3. #3
    SitePoint Enthusiast Mr Toner's Avatar
    Join Date
    Sep 2003
    Location
    Southern California, USA
    Posts
    78
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The ID in "http://example.org/track.php?id=112" is used to look up the href. The script then does a header() redirect to go to that location (in the meantime updating the counter for that href).

    Am I being silly here? Since header() -- according to PHP.net -- does a 302 redirect, do I need to worry that SEs are first seeing an internal link? (Since they were seeing an internal link, I thought I needed to use an external link and use Javascript to change it to the tracker.)


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
  •