1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Integrating Analytics To My Site...

Discussion in 'PHP' started by venkat penmetsa, Jan 24, 2015.

  1. #1
    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??
     
    venkat penmetsa, Jan 24, 2015 IP
  2. Mrtvac

    Mrtvac Member

    Messages:
    77
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    43
    #2
    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.
     
    Mrtvac, Jan 24, 2015 IP
  3. freelanceDeveloper

    freelanceDeveloper Member

    Messages:
    59
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    43
    #3
    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
     
    Last edited: Jan 26, 2015
    freelanceDeveloper, Jan 26, 2015 IP
  4. Mrtvac

    Mrtvac Member

    Messages:
    77
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    43
    #4
    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.
     
    Mrtvac, Jan 27, 2015 IP
  5. HolyRoller

    HolyRoller Well-Known Member

    Messages:
    552
    Likes Received:
    27
    Best Answers:
    1
    Trophy Points:
    150
    #5
    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
     
    HolyRoller, Jan 29, 2015 IP
  6. Mrtvac

    Mrtvac Member

    Messages:
    77
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    43
    #6
    Exactly @HolyRoller . That are my thoughts also. I learn that on hard way ;)
     
    Mrtvac, Jan 29, 2015 IP
    HolyRoller likes this.