SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: counters

  1. #1
    SitePoint Member
    Join Date
    Jan 2004
    Location
    canada
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    counters

    I can't get my counter to work for my site.
    I am using sympatico. I'm not doing anything wrong I think.
    Does you counter have to go on your home page or can it go on any page you want?

  2. #2
    Free your mind Toly's Avatar
    Join Date
    Sep 2001
    Location
    Panama
    Posts
    2,181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can use counters on any page you want, but you'd need a different counter for each page.

    Provide a link to where you have the counter.
    Community Guidelines | Community FAQ

    "He that is kind is free, though he is a slave;
    he that is evil is a slave, though he be a king." - St. Augustine

  3. #3
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I use a javascript/perl counter, that you could have on as many pages as you want, but it will only count unique visitors as the javascript gets cached for each session.

    here's how....
    start by creating an external js file that just contains one variable which is your counter
    Code:
    var index_Counter=8673
    and save as indexCount.js

    next set up a perl or php document that reads the indexCount and increments it by one.
    Here's my perl one.....(saved as indexAdd.cgi)
    Code:
    #!C:/Perl/bin/perl
    use strict;
    use CGI ':standard';
    my $pageC;
    open (Counter, "<indexCount.js") || Error ('open','file');
    my @pageC=<Counter>;
    close (Counter) || Error ('close','file');
    @pageC=split (/=/,@pageC[0]);
    $pageC=@pageC[1];
    $pageC++;
    open (Counter, ">indexCount.js") || Error ('open','file');
    flock (Counter,2) || Error ('lock','file');
    print Counter "var indexCount=".$pageC;
    close (Counter) || Error ('close','file');
    print "Content-Type: application/x-javascript\n\n";
    print "var indexCount=".$pageC;
    which reads the first line ( the variable ), splits the "=" which gets the number, increments it by 1, saves it and outputs the new variable, as in the last line.
    Code:
    print "var indexCount=".$pageC;
    and to activate it you just call the perl in the same way you call a js file....
    Code:
    <script src="cgi-bin/indexAdd.cgi" type="text/javascript"></script>
    and you will be then able to access the variable indexCount

    hope it helps......

    You can just save a number, but I chose to save it as a js file so I can access just the counter without incrementing it using the normal way of loading an external js file.
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if


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
  •