2578 posts Put a Donk On It
  • Has referred 200+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+10 more
ThemeProvince says

Hey guys here’s an easy way to track your items using simple php and text files.

1. Create a text file. Call it no_of_hits.txt. Leave it empty.

2. Create a php file and call it counter.php.

3. Here is the php code i created. Place it in the counter.php. Follow the comments.


<?php // This gets the figure inside the text file.

$number_of _hits = file_get_contents("no_of_hits");

// We give our item a unique id

if ($_GET["id"] == 1) {

 $hits = $hits + 1; 

}

// We add the the new visitor hit.

$number_of_hits = $number_of_hits + 1;

// Open our document

$manage_hits = fopen("no_of_hits.txt", "w"); 

// Replace the old hit counter

fwrite($manage_hits, $hits); 

// Close and save the file.

fclose($manage_hits);

// Print our item's hits.

print "Your item has $hits hits";

?>

4. Save and upload to your server or host.

5. On your item page place an image tag at the bottom.


<img src="http://www.yourwebsite.com/counter.php?id=1" />

Get your item id that we defined earlier and replace with mine above. You can leave it at 1 if you want.

6. Sit back and enjoy. :)

Only when someone visits your item’s page will the counter activate. therefore refreshing on the exact location of php doc wont increase the number of hits.

2578 posts Put a Donk On It
  • Has referred 200+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+10 more
ThemeProvince says

EDIT : replace

$number_of _hits = file_get_contents(“no_of_hits”);

with

$number_of_hits = file_get_contents(“no_of_hits.txt”);

767 posts
  • Has been part of the Envato Community for over 5 years
  • Has sold $1,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Sells items exclusively on Envato Market
+2 more
outandouter says

Now this is cool! great work…

2578 posts Put a Donk On It
  • Has referred 200+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+10 more
ThemeProvince says

The top post has some errors… but this is a working version…

Download the source code here:

Click here to download a working version.

Click here to see a live example currently tracking my item.

3748 posts
  • Has referred 200+ members
  • Has sold $125,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Won a competition
+9 more
pezflash says

Nice share! Thank you Phoenix.

9 posts
  • Has sold $100+ on Envato Market
  • Sells items exclusively on Envato Market
  • Has been part of the Envato Community for over 1 year
  • Located in Netherlands
F4LLCON says

Does this still work? I am trying a similar thing, but it does not load it? I have an googleanalytics.html on the server, a pageloader.php that loads the .html file, and then I am using <img src=”http://website.com/pageloader.php” />.

When I directly go to the site http://website.com/pageloader.php, analytics confirms I am on it, but when I go on my profile on 3DOCEAN, it does not show I am on the profile.

Did 3DOCEAN fix this or am I doing something wrong?

66 posts
  • Has sold $100+ on Envato Market
  • Has collected 1+ items on Envato Market
  • Contributed a free file of the month
  • Made it to the Authors' Hall of Fame
+3 more
yuanhao_viva says

thanks man,really useful

by
by
by
by
by
by