homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

Tracking button/image

 3:25 pm on Feb 8, 2006 (gmt 0)

is it easy to use php to track if some one clicks on of my images/buttons and them put this in a database?



 6:20 pm on Feb 8, 2006 (gmt 0)

Sure. But put what in the database?


 5:02 pm on Feb 9, 2006 (gmt 0)

i want to track if the button is clicked and then


random id

does that help?


 5:31 pm on Feb 9, 2006 (gmt 0)

every link would have to go through a script then, might devalue internal links as they would all go to the same script except with a different id


 5:55 pm on Feb 9, 2006 (gmt 0)

thanks for the reply but that means nothing to me!


 6:31 pm on Feb 9, 2006 (gmt 0)

for the button/image you should use a link like this:

where productId=1 changes for each of your products (productId=2, productId=3, .....)

$randid = rand(0,100000); - generates rand number from 0 to 100000
using the productId you can query your products DB and get the product's price and store in variable $productPrice

Using such a query you can add all the data in your track DB
INSERT INTO track_table ('$randid', now(), '$productId', '$productPrice')

so if someone clicks on track.php?productId=1 it will write in your DB the ID=1, product price, current time and random ID


 6:31 pm on Feb 9, 2006 (gmt 0)


if you want to track every click you will need every link to go through a script that can insert the info into the db before you send them off to the desired page.

every link on your site will then go to this tracking script

have you looked into a log analyzer, maybe clicktracks, as that is probably a better option.


 12:25 pm on Feb 11, 2006 (gmt 0)

excellent thanks for the great feedback i will look in to these options.



 5:07 pm on Feb 11, 2006 (gmt 0)

this way you may be able to track all clicks,
but be careful, its not that much bright idea if you consider SEO of the site.
giving all internal links the same page and that too not using the proper keywords will decrease its chances by a great deal.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved