Parsing and writing URL parameter

I am trying to figure out how to handle tracking of my site visitors and have decided to do the following: in each link that I publish (either in emails or banner ads), I will add a ?[parameter] to the URL link so that I can track the source of the visit.

Now, where I need some help is what kind of scripting can I use in my index.htm file to handle parsing and recording this information into a flat file on the server. I want this flat file to be appeneded to every time someone comes to the website (so the script will append write to the file). Any suggestions or, better yet, sample source code that I can use for this???

Just to be clear, my idea is something like this:

link out on net: www.noworkzone.com?source=optinmsg1

As soon as someone comes to my site with this link, the script would retrieve the source parameter, add a date/time stamp, and add this line "optinmsg1, 05/23/2002 11:00 am[cr]" to a flat file on the server called "visitors.txt"

I hope one of you technical gurus finds a generous side to help this technically challenged entrepeneur...

Comments

  • If the server supports php you can use the following:

    create a textdocument and call it something like log.php

    [code]




    <?php
    touch("Logfile.txt");
    $file = fopen("Logfile.txt","a"); // a = append
    if($file) {
    $Line = date("d-m-y")." - $source"; // $source represents the parameter source wich contains the value optinmsg1
    fputs($file,$Line);
    fclose($file); // We close the file again.
    }else{
    echo "Could not open the logfile";
    }
    ?>







    [/code]

    link to this documetn like

    MyFile.html

    for more information about php programming visit php.net or see the messageboards here at programmersheaven...


    : I am trying to figure out how to handle tracking of my site visitors and have decided to do the following: in each link that I publish (either in emails or banner ads), I will add a ?[parameter] to the URL link so that I can track the source of the visit.
    :
    : Now, where I need some help is what kind of scripting can I use in my index.htm file to handle parsing and recording this information into a flat file on the server. I want this flat file to be appeneded to every time someone comes to the website (so the script will append write to the file). Any suggestions or, better yet, sample source code that I can use for this???
    :
    : Just to be clear, my idea is something like this:
    :
    : link out on net: www.noworkzone.com?source=optinmsg1
    :
    : As soon as someone comes to my site with this link, the script would retrieve the source parameter, add a date/time stamp, and add this line "optinmsg1, 05/23/2002 11:00 am[cr]" to a flat file on the server called "visitors.txt"
    :
    : I hope one of you technical gurus finds a generous side to help this technically challenged entrepeneur...
    :

    ;-)
    -mac-
    mailto:programmersheaven@mac-doggie.nl
    the Netherlands...


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion