php script tracking number of clicks

10 replies
i want a redirect script to be able to tell me how many times it has been clicked on. i dont know what to search for or how to write the code.

i want to see if redirecting to my site or directly to product page makes a difference in the conversion rate.

this is the simple redirect code i use
<HTML>
<HEAD>
<META HTTP-EQUIV="Refresh" CONTENT="0; URL=http://mysitedotcom/courses/learn-more.php">
<TITLE>redirect to</TITLE>
</HEAD>
<BODY>
</BODY>
</HTML>

what is the code to add to be able the see the number of clicks?
and if it's just a mater of adding more code how would i read the results, where would i see the number of clicks?

thanks for your help;
maryjane
#clicks #number #php #script #tracking
  • Profile picture of the author indexphp
    you can set up Prosper202 and process your clicks through that script.
    {{ DiscussionBoard.errors[2556396].message }}
  • Profile picture of the author caesargus
    Check out google analytics if you haven't had a chance. The service is free, and easy to install. There are some extra code that you can add to your site to view different goals and conversions.

    I can help you set it up on your website if you need it as well, depending on what you're tracking etc.
    {{ DiscussionBoard.errors[2557794].message }}
  • Profile picture of the author nevadasoft
    Originally Posted by maryjane123 View Post

    i want a redirect script to be able to tell me how many times it has been clicked on. i dont know what to search for or how to write the code.

    i want to see if redirecting to my site or directly to product page makes a difference in the conversion rate.

    this is the simple redirect code i use
    <HTML>
    <HEAD>
    <META HTTP-EQUIV="Refresh" CONTENT="0; URL=xxxxxxxxx">
    <TITLE>redirect to</TITLE>
    </HEAD>
    <BODY>
    </BODY>
    </HTML>

    what is the code to add to be able the see the number of clicks?
    and if it's just a mater of adding more code how would i read the results, where would i see the number of clicks?

    thanks for your help;
    maryjane
    Open Notepad (or any plain text editor) and save this as clicks.php (change "xxxxxxxxxx" to your real URL you want to redirect to):

    <?php
    $x=file_get_contents('clicks.txt');
    if ($x) { $x++; } else { $x=1; }
    file_put_contents('clicks.txt',$x);
    header("Location: xxxxxxxxxx");
    ?>

    Now also save a blank text file called clicks.txt

    Upload both to any domain. Send traffic to the clicks.php script, check the clicks.txt file for the click count.

    If it doesn't work you'll need to change the file permissions of clicks.txt to 666 (Google "Filezilla", download and install it, FTP to the place where clicks.txt is, right click it and choose "file permissions" and set it to 666).

    Or just use a clicktracker :-)
    {{ DiscussionBoard.errors[2557889].message }}
    • Profile picture of the author hhunt
      Originally Posted by nevadasoft View Post

      Open Notepad (or any plain text editor) and save this as clicks.php (change "xxxxxxxxxx" to your real URL you want to redirect to):

      <?php
      =file_get_contents('clicks.txt');
      if () { ++; } else { =1; }
      file_put_contents('clicks.txt',);
      header("Location: xxxxxxxxxx");
      ?>

      Now also save a blank text file called clicks.txt

      Upload both to any domain. Send traffic to the clicks.php script, check the clicks.txt file for the click count.

      If it doesn't work you'll need to change the file permissions of clicks.txt to 666 (Google "Filezilla", download and install it, FTP to the place where clicks.txt is, right click it and choose "file permissions" and set it to 666).

      Or just use a clicktracker :-)
      This is one of the best sample instructions I've seen on this forum - simple and straight to the point. It works like a dream.

      Thanks for the code.
      {{ DiscussionBoard.errors[2558174].message }}
      • Profile picture of the author Makeitso
        Originally Posted by hhunt View Post

        This is one of the best sample instructions I've seen on this forum - simple and straight to the point. It works like a dream.

        Thanks for the code.
        I totally agree. Help like this keeps me coming back!
        {{ DiscussionBoard.errors[2558224].message }}
    • Profile picture of the author onewayback
      Originally Posted by nevadasoft View Post

      Open Notepad (or any plain text editor) and save this as clicks.php (change "xxxxxxxxxx" to your real URL you want to redirect to):

      <?php
      =file_get_contents('clicks.txt');
      if () { ++; } else { =1; }
      file_put_contents('clicks.txt',);
      header("Location: xxxxxxxxxx");
      ?>

      Now also save a blank text file called clicks.txt

      Upload both to any domain. Send traffic to the clicks.php script, check the clicks.txt file for the click count.

      If it doesn't work you'll need to change the file permissions of clicks.txt to 666 (Google "Filezilla", download and install it, FTP to the place where clicks.txt is, right click it and choose "file permissions" and set it to 666).

      Or just use a clicktracker :-)
      You...are...awesome! Youve got a great mind for it!I'm really lucky to read your post. This piece of info really courage me. Thanks.
      {{ DiscussionBoard.errors[2562676].message }}
      • Profile picture of the author nevadasoft
        Originally Posted by onewayback View Post

        You...are...awesome! Youve got a great mind for it!I'm really lucky to read your post. This piece of info really courage me. Thanks.
        Thank you! It was my first post so I thought I better make it a good one.
        {{ DiscussionBoard.errors[2563632].message }}
    • Profile picture of the author davidsbain
      Very Nice ! Thanks for contributing a very helpful piece of code. I will be testing this out.
      {{ DiscussionBoard.errors[2567119].message }}
  • Profile picture of the author zeeshi570
    user SERVER array to check from where it is redirecting to ur site and then just add them to database
    {{ DiscussionBoard.errors[2558094].message }}
  • Profile picture of the author maryjane123
    cant use google analytics. SERVER array is a bit over my head. Prosper202 looks pretty good and so does nevadasoft explanation.

    thank you everyone for your help.
    {{ DiscussionBoard.errors[2559272].message }}

Trending Topics