Hi,every one I'm going to build a URL shortner in PHP. Every user shorten some links but I need to show analytics to every links that are shortened. help me out plz??
I'm not going to talk about why not to start another sort url service, but if you plan to have analytics for every link, then you better prepare large and fast servers. It's hard to just put some code for storing analytics so, if your'e new to PHP, I suggest you to download or buy some ready-made scripts. You can find some pretty good one and cheap in Marketplace on this site (https://marketplace.digitalpoint.com/scripts.3/category) Regards.
www.yohis.com/url/dpforum In above example 'dpforum' is your key and you could easily store all wanted information in a table using this unique key as reference. If you want basic data you could fe : "update stats set pageviews = pageviews + 1 , IE = IE+$IECOUNT , FF = FF + $FFCOUNT where id='$id'" PHP: creating 1 record / url that you update continually IECOUNT & FFCOUNT are initiated to 0 and set to 1 based on the browser detected $IECOUNT = ($is_explorer==true) ? 1 : 0; $FFCOUNT = ($is_firefox==true) ? 1 : 0; PHP: resulting when firefox is used "update stats set pageviews = pageviews + 1 , IE = IE+0 , FF = FF + 1 where id='$id'" PHP: If you want to keep track of all referrer urls , then 1 row/pageview could be used, this would in time create huge database tables... Using indexes on the columns you want to use in your stat queries is advised or create some predefined views Don't think that results in excessive server requirements
This are stats only for hits (pageviews, IE and FF). What about other browsers? Referrer? Location? Language? Desktop/mobile? And many other analytics. It's not just problem for disk space but for operations also (you need to save all that data for every page hit). Of course, I'm telling all this only if he plans to run service with millions of links and hits.
The advertising company I work for is getting over a billion ad impressions a month, it is amazing the issues this can cause especially during peak periods. Also as the need to start storing more information such as device type, browser, etc has become neccessary this has highlighted the issue. Definitely worth considering this from the start, because if it ever does get to millions of links/hits it is much easier to have planned from the start as it will save a massive amount of time and money. If it doesn't get that successful, you probably will have still saved money and learnt some valuable skills. Quite an interesting article on Twitter and scalability here http://highscalability.com/blog/201...res-250-million-tweets-a-day-using-mysql.html