Hit Counter For Craigslist Postings

rusty.nells

New Member
Reaction score
0
Location
Republic Of Texas
Anybody sell or advertise on craigslist?

Here's a little php script I put together to see how many page views my posts get. Whenever someone views my post, I get an email. The email is filtered and sent to it's own folder where I can easily get a count. You could also mod this to save data in a database or display an actual counter in the post.

This requires a web server with php and sendmail() enabled.

First, copy the following code and save as "view.php"

PHP:
<?
if(isset($_GET['item']))
{
$ua = $_SERVER['HTTP_USER_AGENT'];

$ref =	$_SERVER['HTTP_REFERER'];

$viewer = $_SERVER['REMOTE_ADDR'];

$item = $_GET['item'];

$Name = "Viewer";

$email = "myaddress@mydomain.com";

$recipient = "myaddress@mydomain.com"; //enter your own email address

$mail_body = "IP address is $viewer\n
		Referrer is $ref\n\n
		User Agent is $ua\n\n
		More IP info - http://www.ip-adress.com/ip_tracer/?QRY=$viewer";

$subject = "$item Viewed by $viewer";

$header = "From: ". $Name . " <" . $email . ">\r\n";

mail($recipient, $subject, $mail_body, $header);

header("Location: index.php");
}

else

header("Location: index.php");
?>

You might want to change the $email variable. You'll definitely need to change the $recipient variable, enter your own email address. Save and upload to your web server.

Then (assuming you uploaded to the root directory) insert the following code in to your craigslist post. Edit MYWEBSITE.COM and YOUR_ITEM_NAME
HTML:
<img src=http://MYWEBSITE.COM/view.php?item=YOUR_ITEM_NAME width=0 height=0>

This should work on other sites that allow the IMG tag.
 
Anybody sell or advertise on craigslist?

Here's a little php script I put together to see how many page views my posts get. Whenever someone views my post, I get an email. The email is filtered and sent to it's own folder where I can easily get a count. You could also mod this to save data in a database or display an actual counter in the post.

This requires a web server with php and sendmail() enabled.

First, copy the following code and save as "view.php"

PHP:
<?
if(isset($_GET['item']))
{
$ua = $_SERVER['HTTP_USER_AGENT'];

$ref =	$_SERVER['HTTP_REFERER'];

$viewer = $_SERVER['REMOTE_ADDR'];

$item = $_GET['item'];

$Name = "Viewer";

$email = "myaddress@mydomain.com";

$recipient = "myaddress@mydomain.com"; //enter your own email address

$mail_body = "IP address is $viewer\n
		Referrer is $ref\n\n
		User Agent is $ua\n\n
		More IP info - http://www.ip-adress.com/ip_tracer/?QRY=$viewer";

$subject = "$item Viewed by $viewer";

$header = "From: ". $Name . " <" . $email . ">\r\n";

mail($recipient, $subject, $mail_body, $header);

header("Location: index.php");
}

else

header("Location: index.php");
?>

You might want to change the $email variable. You'll definitely need to change the $recipient variable, enter your own email address. Save and upload to your web server.

Then (assuming you uploaded to the root directory) insert the following code in to your craigslist post. Edit MYWEBSITE.COM and YOUR_ITEM_NAME
HTML:
<img src=http://MYWEBSITE.COM/view.php?item=YOUR_ITEM_NAME width=0 height=0>

This should work on other sites that allow the IMG tag.


This is fantastic. I dont want it to e-mail but I would like for it to keep a count on the page. What do I modify? I am not good at scripting.

From what I can tell this is set to e-mail (after we add our own e-mail address)
 
This is fantastic. I dont want it to e-mail but I would like for it to keep a count on the page. What do I modify? I am not good at scripting.

From what I can tell this is set to e-mail (after we add our own e-mail address)

It shouldn't be too hard to create. You'd need a database or text file to store the count. Also need to create a blank image and print the count on the image.

You'd also have to filter the input because anybody could manipulate the query string.

If I can find the time (and motivation) I'll see what I can put together. Might be a few months:D
 
It shouldn't be too hard to create. You'd need a database or text file to store the count. Also need to create a blank image and print the count on the image.

You'd also have to filter the input because anybody could manipulate the query string.

If I can find the time (and motivation) I'll see what I can put together. Might be a few months:D

Dang I knew that I should have taken scripting and HTML.
 
I just found a craigslist posting with a counter but I dont see when I go to view source I dont see when the counter is. The image does not go else where like photobucket etc.

That could be cool to have. That way I can check how many people seen the add.
 
Lol
well if all the usual javascripts page counters from the normal cut and paste sites found via google don't work, would any javascript work at all

I am not familiar with Craiglist, doesn't apply to me in my country (to my knowledge) I can actually say I've NEVER visited the site. Is there a page that lists which scripts are applicable in an ad? Or anything similar?

*** EDIT ***

@LunchBox

suck up ;)
 
Yeah i know it required server-side scripting, somethin' needs to calculate and store the data .

As previous, I have never visited CL so I don't know what it allows.
Well now that I know that you can't use JS, click here
 
Well I went there, and left 5 seconds later..

Whats the deal with Craigslist anyway? It looks like a cheap rip-off of yellow pages lol

LOL . Yeah it a classified ad online. Very popular. I worked once at a place one that posted "free office furniture" within 30 minutes it was gone.

I tried that link you posted (that was the first one I come across) but it didnt work. Maybe I just suck at copying and pasting.

When you see pizza techs, they a lot of time mean the techs that post at craigslist for $20 jobs.
 
I'm sure if people use there common sense then they would figure that $20 isn't really ideal for gettin' your PC fixed. Thats just a little too cheap; ecspecially when everyone has a "friend who knows computers", which is what im assuming all the 'pizza techs' that post $20 job ads on CL.

Lol I didn't wanna pay out CL to much incase I got flamed about it before, cos i know a few people on here use CL. But anyway, it looks like a 12-year old script kiddie who just learnt how to use <table> <tr> and <td> tags in HTML lol

Copy and paste this;

http://www.ecommerce-blog.org/archives/how-to-track-craigslist-ads/


It mentions HTML only counters, which directs you to hitslog.com and statcounter.com

If you can't get that one right, donate some money into my PayPal and I'll write you a tutorial on how to copy some text, and paste it into a address bar of a browser, it is quite complex, and I'm sure I could stretch it out to 20 step tutorial lol buddy, pal :D
 
I just put together a script for you. It's late (yawn) so I will post it later this weekend. You owe me :D

It requires PHP with GD and MySQL

I finally discovered what I was doing wrong with the code I found on the internet. I was just pasting straight into craigslist. I did not know I had to create at account (which is free). The counter has no advertisement around it unless you click in the counter which takes you to the hit counter web page. Now I know how many people see my ads. I created two counters one for each ad to see which one gets more hits.

I dont have a website yet. But once I do having a counter not tied to some other site is much better.
 
Back
Top