where do they go? How can I gather Click info in PHP

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • windandwaves

    where do they go? How can I gather Click info in PHP

    Hi Folk

    I was wondering if it is possible to find out what people click on, using
    PHP.

    For example, I have a PHP page with an email link and some third party links
    (e.g. www.someone-else.com). I want to know where people go.

    My own solution would be to make the link not to an email or a third-party
    website, but to another page along the lines of

    <?php
    //check out where it came from and where it is going
    //write info to database
    header = {where it should be going}




    ?>

    I am not sure if you can do this with email, but I am also wondering if
    there is an easier/smarter way to do this.

    Cheers

    - Nicolaas


  • Janwillem Borleffs

    #2
    Re: where do they go? How can I gather Click info in PHP

    windandwaves wrote:[color=blue]
    > I am not sure if you can do this with email, but I am also wondering
    > if there is an easier/smarter way to do this.
    >[/color]

    The header solution can only be used for normal links, not with email links
    with the "mailto:" pseudo protocol.

    But email links can, of course, link to an email form, so you can catch them
    there.

    Other solutions involve JavaScript, but you cannot rely on this because the
    client can switch it off.


    JW



    Comment

    • windandwaves

      #3
      Re: where do they go? How can I gather Click info in PHP

      Janwillem Borleffs wrote:[color=blue]
      > windandwaves wrote:[color=green]
      >> I am not sure if you can do this with email, but I am also wondering
      >> if there is an easier/smarter way to do this.
      >>[/color]
      >
      > The header solution can only be used for normal links, not with email
      > links with the "mailto:" pseudo protocol.
      >
      > But email links can, of course, link to an email form, so you can
      > catch them there.
      >
      > Other solutions involve JavaScript, but you cannot rely on this
      > because the client can switch it off.
      >[/color]

      Thank you for your answer, sounds like I may have to do something creative.

      Cheers


      - Nicolaas


      Comment

      • Guenther Schmidt

        #4
        Re: where do they go? How can I gather Click info in PHP

        Windandwaves

        this is acutally rather easy.

        the link that people click on should be something like:

        <a href="/redirect.php?de stinationURL=ww w.cnn.com">www. cnn.com</a>


        in redirect.php

        you would code whatever is necessary to write the destination URL into the database and then redirect the visitor to the intended destination by doing:

        header ('Location: '.$_REQUEST['destinationURL ']);

        that's all.

        If you want to find out *where they come from* there is a variable called HTTP_REFER or something like that. Study the output of phpinfo(); to find the exact name.

        There is a tutorial/article for exactly this called "where they went, where they came from" on
        The energetic, vibrant digital home of developers that are passionate and dedicated to sharing and learning more about PHP. PHP snippets, PHP tutorials and PHP Forums.


        Good luck!

        Günther




        windandwaves wrote:[color=blue]
        > Hi Folk
        >
        > I was wondering if it is possible to find out what people click on, using
        > PHP.
        >
        > For example, I have a PHP page with an email link and some third party links
        > (e.g. www.someone-else.com). I want to know where people go.
        >
        > My own solution would be to make the link not to an email or a third-party
        > website, but to another page along the lines of
        >
        > <?php
        > //check out where it came from and where it is going
        > //write info to database
        > header = {where it should be going}
        >
        >
        >
        >
        > ?>
        >
        > I am not sure if you can do this with email, but I am also wondering if
        > there is an easier/smarter way to do this.
        >
        > Cheers
        >
        > - Nicolaas
        >
        >[/color]

        Comment

        • windandwaves

          #5
          Re: where do they go? How can I gather Click info in PHP

          Guenther Schmidt wrote:[color=blue]
          > Windandwaves
          >
          > this is acutally rather easy.
          >
          > the link that people click on should be something like:
          >
          > <a href="/redirect.php?de stinationURL=ww w.cnn.com">www. cnn.com</a>
          >
          >
          > in redirect.php
          >
          > you would code whatever is necessary to write the destination URL
          > into the database and then redirect the visitor to the intended
          > destination by doing:
          > header ('Location: '.$_REQUEST['destinationURL ']);
          >
          > that's all.
          >
          > If you want to find out *where they come from* there is a variable
          > called HTTP_REFER or something like that. Study the output of
          > phpinfo(); to find the exact name.
          > There is a tutorial/article for exactly this called "where they went,
          > where they came from" on http://www.phpbuilder.com
          >
          > Good luck!
          >
          > Günther
          >
          >
          >
          >
          > windandwaves wrote:[color=green]
          >> Hi Folk
          >>
          >> I was wondering if it is possible to find out what people click on,
          >> using PHP.
          >>
          >> For example, I have a PHP page with an email link and some third
          >> party links (e.g. www.someone-else.com). I want to know where
          >> people go. My own solution would be to make the link not to an email or a
          >> third-party website, but to another page along the lines of
          >>
          >> <?php
          >> //check out where it came from and where it is going
          >> //write info to database
          >> header = {where it should be going}
          >>
          >>
          >>
          >>[color=darkred]
          >>>[/color]
          >>
          >> I am not sure if you can do this with email, but I am also wondering
          >> if there is an easier/smarter way to do this.
          >>
          >> Cheers
          >>
          >> - Nicolaas[/color][/color]


          Thanks a lot Günther.


          Comment

          • windandwaves

            #6
            Re: where do they go? How can I gather Click info in PHP

            Guenther Schmidt wrote:[color=blue]
            > Windandwaves
            >
            > this is acutally rather easy.
            >
            > the link that people click on should be something like:
            >
            > <a href="/redirect.php?de stinationURL=ww w.cnn.com">www. cnn.com</a>
            >
            >
            > in redirect.php
            >
            > you would code whatever is necessary to write the destination URL
            > into the database and then redirect the visitor to the intended
            > destination by doing:
            > header ('Location: '.$_REQUEST['destinationURL ']);
            >
            > that's all.
            >
            > If you want to find out *where they come from* there is a variable
            > called HTTP_REFER or something like that. Study the output of
            > phpinfo(); to find the exact name.
            > There is a tutorial/article for exactly this called "where they went,
            > where they came from" on http://www.phpbuilder.com
            >
            > Good luck!
            >
            > Günther[/color]


            Here is what I did:

            //link to database

            $bot = browser_detecti on("type");
            if(strlen($p) == 3){
            $pageowner= $p;
            }
            if($h == 1) {
            $httper = "http://".$pageownerweb site;
            }
            elseif($h == 2) {
            $httper = "http://".$pageownersec ondsite;
            }
            else {
            $httper = "http://www.myurl.co.nz/404.php";
            }
            $sqllog = 'INSERT INTO `LOG` ( `field1` , `field2` , `field3`, `field4` )
            VALUES (NOW() , "'.$pageowner.' ", "clicked","'.$h ttper.' ('.$bot.')" );';
            $logger = mysql_query($sq llog);
            $locationer = $httper;
            header("Locatio n: $locationer");

            ?>

            It seems to be working well.


            Comment

            Working...