Retrieving Google Analytics Data to Build a KPI Dashboard

October 26, 2015 Leave a comment


As we all know, many web projects are created in order to solve particular business needs. Any business requires data on how well it is going, how big the traffic of clients is, how many clients register, etc..

Google Analytics is an industry standard service to collect such data. The site webmaster puts a JavaScript tracker script in the pages to allow Google Analytics to collect the data for every time a page is loaded.

Google Analytics Charts

All that is done on front-end site, no PHP code is involved. In this article I cover retrieving access statistics data from Google Analytics using PHP.

Retrieving Google Analytics Data to Build a KPI Dashboard

Project owners and investors might need a dashboard or KPI progress page. Let’s see how to grab statistics from your Google Analytics account to s PHP backend in order to build a dashboard.

There are many statistics that represent the heartbeat of your project: number of visitors, bounce rate, percent of registrations, profit from every user, etc. These are called KPIs: the key performance indicators, each of which is a business metric used to evaluate factors that are crucial to the success of an organization.

KPIs differ from one company to another.  Some of these indicators can be seen in original Google Analytics reports: how many people came and how engaged they are in average. What your customer might want is to combine that data with revenue and profit data from your database and build a solid dashboard.

At this point you will realize that you need to retrieve Google Analytics data from your PHP scripts.
Hold on, Google Analytics is a complex data source, —entries can be queried by date and name.

You will find an couple of classes below that help to automate interaction with this service and return a simple number as result of your query. The code is based on Zend Framework 1, since it helps a lot to automate interaction with Google services (a technology called GData).

First, let’s create an abstract class to help us create classes to work with different Google Services (just replace XXX with your app or library name)


class XXX_Google_Wrapper_Abstract {

    public $gdClient; 
    protected $_listFeedsUrl;
    protected $_dataUrl;
     * Constructor for the class. Takes in user credentials and
     * generates the the authenticated client object.
     * @param  string $email    The user's email address.
     * @param  string $password The user's password.
     * @return void
    public function __construct( $email, $password, $service) {
        $client = Zend_Gdata_ClientLogin :: getHttpClient( $email, $password, $service);
        $this->gdClient = new Zend_Gdata( $client );

    protected function __fetch($url) {
        $query = new Zend_Gdata_Query($url);
        $feed = $this->gdClient->getFeed($query);
        return $feed;
    public function listFeeds() {
        return $this->__fetch($this->_listFeedsUrl);
    public function fetchItems(array $params) {
        $url = $this->_dataUrl . '?' . http_build_query($params);
        return $this->__fetch($url);

Now, we can use this parent class to create a class to work with Google Analytics:


class XXX_Google_Wrapper_Analytics extends XXX_Google_Wrapper_Abstract {
    protected $_listFeedsUrl = '' . '/analytics/feeds' . '/accounts/default';
    protected $_dataUrl = '' . '/analytics/feeds/data';
    public function __construct( $email, $password) {
        parent::__construct( $email, $password, 'analytics');

Both classes must be placed anywhere where your scripts can automatically load them. Zend Framework provides a simple naming convention to make it work automatically.

Google Analytics data is very flexible — e.g., you can grab total visits count, or visits of a page that contains a particular keyword in its URL. So we need one more abstract class, that we will use our Google Analytics wrapper to access any kind of required data:

abstract class Stats_Google_Analytics_Abstract {
    protected static
    protected $_page;
    public function __construct() {
        if (!empty(self::$_wrapper)) return true;
        $config = Zend_Registry::get( 'config' ) -> toArray();
        $analyticsConfig = &$config[ 'google' ][ 'analytics' ];
        $email    = $analyticsConfig['email'];
        $password = $analyticsConfig['password'];
        self::$_reportID = $analyticsConfig['report']['id'];
        try {
            self::$_wrapper = new Sunny_Google_Wrapper_Analytics( $email, $password);
        catch(Zend_Gdata_App_AuthException $e) {
            error_log( 'Zend_Gdata_App_AuthException: ' . $e->getMessage() );
            throw $e;
    public function fetchValue( $startDate, $endDate = null, array $additionalParams = null) {
        $list = $this->fetchAll( $startDate, $endDate, $additionalParams );
        $sum = array_sum($list);
        return $sum;
    public function fetchAll($startDate, $endDate=null, array $additionalParams = null) {
        if (empty( $endDate )) {
            $endDate = $startDate;
        $params = $additionalParams;
        $params['start-date']   = date('Y-m-d', strtotime( $startDate ));
        $params['end-date']     = date('Y-m-d', strtotime( $endDate ));
        $params['ids']          = self::$_reportID;
        try {
            $result = self::$_wrapper->fetchItems( $params );
        catch(Exception $e) {
            error_log('Exception: ' . $e->getMessage());
            throw $e;
        $dimensions = array();
        foreach ($result as $entry) {
            $extensions = $entry -> getExtensionElements();
            $attrs = array();
            foreach ($extensions as $extension) {
                $attributes = $extension -> getExtensionAttributes();
                $attrs[ $extension->rootElement ] = $attributes;
                $value  = $attributes[ 'value' ][ 'value' ];
                ${$extension -> rootElement} = $value;
            if (empty($dimension)) {
                $dimension = null;
            $dimensions[ $dimension ]  = $metric;
        return $dimensions;
     * Returns amount of unique visitors in the given time period
     * @param string $fromDate
     * @param string $toDate
     * @return int
    public function count( $fromDate, $toDate = null) {
        $params = array(
            'metrics'       => 'ga:visits',
        if (!empty($this->_page)) {
            $params['filters'] = 'ga:pagePath=~/'.$this->_page.'/*';
        return $this->fetchValue( $fromDate, $toDate, $params );
To make it work, your Zend Framework configuration file must include these settings:      =   = YourPassword  = ga:12345
OK, all is ready. Let’s create a class to grab statistics about all page views from your account:

//yes, it's an empty class since everything is defined in the abstract class
class Stats_Google_Analytics_Visit_Total extends Stats_Google_Analytics_Abstract {

$startDate = '2014-01-01';
$endDate = '2015-10-15';
$tracker = new Stats_Google_Analytics_Visit_Total;
echo $tracker->count( $startDate, $endDate );
This how to count pages that contain ‘/admin/’ in their URL:

class Stats_Google_Analytics_Visit_Admin extends Stats_Google_Analytics_Abstract {

    protected $_page = 'admin';

$tracker = new Stats_Google_Analytics_Visit_Admin;
echo $tracker->count($startDate, $endDate);
As you can see, it’s that easy!
Categories: selvabalaji


March 15, 2014 Leave a comment

We use Facebook to share our toughs(whats on your mind??) , there are many important pages by Facebook to be noted.

# News room home page: link


# KeyFacts: link

The Key factor mentions recent statistics, about the company, no.of employees, Board members and Head quarters for Facebook. It displays all the statistics about the Facebook report and statistical data til last quarter of the year.

# Products of Facebook: link

Th product of Facebook is been listed in product page these ‘n’ number of product is been used by Facebook. The tab is been included with products, timelines, group research, photo , videos and messenger.

#Photos and Broll: link

The Important photos events of particulars is been made album and released in this link.

# Developer Page in Facebook: link

If you are keen interested in developing an apps for Facebook this page is right for you. And get more announcements in this page by the Facebook CEO on the right corner (connected to Facebook blog).

# Carrier @ Facebook: Link

Search job in Facebook based on  countries and job search. This page is really interesting to learn about the responsibilities and requirements on described job position.

# Help @ Facebook: Link 

PC Recovery Tips

March 14, 2014 Leave a comment

Mostly all people think that if anything happen with hard-disk , they looses all the valuable data they have stored.It causes in many cases in day to day life like –

1. Partition loss,
2. Just because of viruses ,they installed New Operating System .
3. Format

All those important file and videos you lost from your partition ,time to get them back . Here i am reviewing a software GetDataBack for NTFS , Using this software you also get back all your valuable data .

First download the software from the link given below –

Download link :

Installation Wizard will start when you click on the setup, follow all the process

Click in the checkbox abd press next

Give location where you want to install and click Next

Click Next

Click Next

Your Installation is complete now , Click on Finish Button and start the software

This is the important window comes infront of you when you start your software application .
There are some options given choose according to your case :

* If you don’t know what to do select default settings
* In case of Partition loss , Perform Quick Scan
* In case someone Format your Drive and you loose all your data then use Systematic file system damage to recover all data.
* Sometimes most of the people installed new operating system just because some files are missing .To recover in this situation choose Sustained file system damage option.
Last option is for those who want to recover only those files which they deleted from harddisk.

Here click on the Physical drive options ,select your Partition
as i have select

2nd partition(NTFS)97.6GB and click on Next Button.

Second step : Select the file system .Your system automatically shows your file system . Here I selected the NTFS at sector 206,848 cluster size 8(97.6 GB). and click Next .
Note : NTFS is the windows file system

Now it will ananlyze your harddisk

Here your will get all your data as shown here !!!!
This is how you will recover your all data

Categories: 2014 Tags: , , ,

10 Blacklisted Hacking countries:

March 14, 2014 Leave a comment

1. China
The Chinese may not always guilty, but have a share of 41% of hacker attacks. Just one year before the Republic of China was responsible for only 13% of cyber attacks according to Akamai, and share in the third quarter was 33%.

2. U.S.
Every tenth hacker attacks worldwide originated in the United States.

3. Turkey
Bronze medal for Turkey, accounting for 4.7%
of global cybercrime.

4. Russia
Russia is considered to defuse the situation from 6.8% to 4.3% October-December 2012.

5. Тaiwan
Taiwanese are responsible for 3.7% of computer
crimes at the end of 2012

6. Brazil
Brazil registered a decline of hacking attacks –
from 4.4% at the end of 2011 to 3.8% in the third quarter of 2012 and 3.3% – in the fourth.

7. Romania
The seventh is Romania with a share of 2.8%.

8. India
India is responsible for 2.4% of hacking attacks worldwide.

Italy’s share falling to 1.6%.

10. Hungary
Hungary is responsible for 1.4% of cyber attacks in
late 2012

Categories: 2014 Tags: , ,

Too many passwords? Solution coming soon

March 14, 2014 Leave a comment
Internet users may before long have a secure solution to the modern plague of passwords.

Internet users may before long have a secure solution to the modern plague of passwords.

HANOVER: Internet users may before long have a secure solution to the modern plague of passwords, in which they can use visual patterns or even their own body parts to identify themselves.

Developers at the world’s biggest high-tech fair, CeBIT, say that one of the biggest frustrations of having a smartphone and a computer is memorizing dozens of sufficiently airtight passwords for all their devices and accounts.

“The problem of passwords is that they are very weak, they are always getting hacked, and also from a user point of view, they are too complicated, everybody has 20, 30, 60 passwords,” said Steven Hope, managing director of Winfrasoft from Britain, the fair’s guest country this year.

“They all have to be different, no one can remember them, so everybody writes them down or resets them every time they log in. They don’t work in the real world today.”

Passwords have proliferated so much that it’s a daily struggle for users to cope with so many of them.

And as millions of internet users have learned the hard way, no password is safe when hackers can net them en masse from banks, email services, retailers or social media websites that fail to fully protect their servers.

Many simply throw in the towel and use no-brainer codes like “123456” and “password” – which are still the most common despite how easily they can be cracked, CeBIT spokesman Hartwig von Sass said at the event in the northern German city of Hanover.

In response to the vulnerabilities and hassles of the antiquated username-and-password formula, Winfrasoft has developed an alternative based on a four-colour grid with numbers inside that resembles a Sudoku puzzle.

Users select a pattern on the grid as their “password” and because the numbers inside the boxes change once per minute, the code changes too, making it far harder to hack.

“There is no way anybody could see which numbers you are looking at. You see typing numbers but you don’t know what the pattern is because each number is here six times,” Hope said during a demonstration.

Biometric data offers another alternative to seas of numbers, letters and symbols.

US giant Apple has already equipped its latest generation iPhone with a fingerprint reader to boost its security profile.

But a group of European hackers, the Hamburg-based Chaos Computer Club, demonstrated that the system could be pirated using a sophisticated “fake” fingerprint made of latex.

Japan’s Fujitsu turned to the other end of the hand and has developed an identification system based on each person’s unique vein pattern.

At its CeBIT stand, the company was showing off its PalmSecure technology on its new ultra-light laptop computer which has a small sensor built in.

Meanwhile Swiss firm KeyLemon has developed a face recognition system using a webcam.

The computer registers parts of the face, “the eyes, the eyebrows, the shape of your nose, your cheekbones, the chin…” a company spokesman said.

The person must then only sit in front of the screen to be recognised and gain access to the computer.

The system, already used by some three million people according to the company, still has a few kinks however so users must remember to take off their eyeglasses, for example, or have consistent lighting in order to pass the identity test.

“Face recognition and fingerprint recognition are additional safety security features, they will never have only face recognition or fingerprint recognition” but rather use them as a crucial backup to passwords, he said.

How to Hunt for a Job Using Social Media

March 14, 2014 Leave a comment

Securing a job is the tough part, but scouting an open position? All it takes is a strategic scroll through your favorite social media accounts.

Sites like Twitter and Facebook can be fun and frivolous, but they’re also viable business opportunities. Plumbing through accounts, hashtags and personal pages could help launch next potential career.

Want to find a writing opportunity in a town near you? Just look up a hashtag on Twitter. Want to stay up to date with a company’s career openings? “Like” them on Facebook. Want to create a beautiful resume that’ll catch a recruiter’s or hiring manager’s eye? Head over to Pinterest.

Here’s how to land your perfect job via social media.

1. Twitter

In 140 characters or less, Twitter can help you find your dream gig. It’s teeming with job applications and professional networking pages, if you know where to find them.

a. Searches: Use that search bar to look for terms that apply to the job you want. For best results, type in words like “jobs,” “hiring” and other specifics that apply to your desired field and location; for example, “writer” and “New York City.”

b. Hashtags: Typing #jobs and #hiring will result in a plethora of tweets from those seeking employees. Employers who want to cast a wide net will often tweet out job applications, with accompanying hashtags.

c. Tweet often: Though it depends on your career of choice, tweeting is a great way to network with like-minded folks in your profession. Follow businesses and people you’re interested in and don’t be afraid to send them the occasional tweet. (On that note, make sure your Twitter account is polished and professional).

d. Follow away: There are dozens and dozens of Twitter accounts dedicated to posting job applications. Go to the search bar and type in “jobs,” then click “People” on the left-hand side. You’ll soon see all the Twitter accounts with “jobs” in the username and can gleefully press the “Follow” button.

2. Facebook

Facebook is an undeniable social media juggernaut. According to its representatives, these are the top tips for trying to get a job through Facebook:

a. “Like” some pages: Most companies strive for dynamic social media presences, and Facebook Pages are engagement 101. By “Liking” them, you can get daily updates about their activity. Plus, they will likely post links to available job applications.

b. Private/Public: Take a thorough look at your privacy settings on Facebook, and make sure you know exactly how others view your Timeline. However, you should consider setting your work and education info public, enabling others to see your professional history.

c. Stay updated: Make sure all of your work and education info is up to date and reflects your current position and past experience.

d. Add “Professional Skills:” A few months ago, Facebook added a “Professional Skills” portion to the “About” section. Underneath work and education, add skills you’ve acquired, optimizing your professional appeal.

3. LinkedIn


Perhaps the most obvious of job hunting sites, LinkedIn is the network of choice for professionals.

a. Connect: Unlike Facebook, it’s a little less creepy to connect with strangers on LinkedIn, because everyone there is looking for networking opportunities. Connect to people who have careers you’re interested in, and search around for those who might only be one degree away from you. For inspiration, check out the member stories portion of LinkedIn’s blog, where users share their success anecdotes about networking through the site.

b. Jobs Board: Not only does the site provide you with advice and connections, but it also has a jobs board highlighting available opportunities in nearly every field.

c. Endorsements and recommendations: There’s a portion of your profile dedicated to glowing recommendations and endorsements from your peers. Try to get as many as you can, and your page’s likability will instantly boost.

d. Share more: According to LinkedIn’s Career Expert, Nicole Williams, sharing articles or content with your network boosts your chances 10 times for getting contacted by a recruiter. When you share content, it proves your knowledge in the industry.

e. List all the things: Your profile is 12 times more likely to be viewed by a hiring manager if you have a detailed list of work experience, Williams says. The more robust your profile is, the more experienced and hirable you look.

4. Tumblr


You can use Tumblr, that vast Internet playground of GIFs and rabid fandoms, for help in the job search.

a. Search tags: In the search bar, look for tagged terms like “hiring” and “jobs.” It’s a bit harder to separate the wheat from the chaff in the tag-happy blogging community, but you’ll still be able to find plenty of cool companies advertising open jobs via Tumblr.

b. Start Tumbling: This is especially important if you’re the creative type. A Tumblr account attuned to your interests, and full of your own original content, automatically ups your unique appeal to employers. In addition, a good Tumblr following can lead to job offers from employers who happened to stumble upon your site.

5. Pinterest


Yes, Pinterest is more than just a pretty place to find wedding inspiration and delicious recipes.

a. Pin your résumé: Tired of the standard, one-sheet format? Use a Pinterest board to “pin” your résumé. You can highlight certain aspects of your experience and add photos and links. See Rachael G. King, a social media manager at Sidecar who created a “living résumé.”

b. Follow these pages: For a never-ending well of job tips and opportunities, follow these seven helpful Pinterest boards.

How To Assess Your Performance Before Appraisals

March 14, 2014 Leave a comment


Self-assessment is very crucial before appearing for your next appraisal. Here’s how you should go about it…
Another year; yet another round of appraisal! But are we prepared yet? Are we certain that we are ready to justify our achievements from last year? Perhaps it’s a yes/no situation. It’s true that one can never be fully prepared for anything, even if he/she claims otherwise. Just like there’s no end to learning; there’s also no end to fine-tune your points before the next appraisal meeting with your reporting manager.
One great way to fine-tune the talking points is to focus on what you did right or things which weren’t in your favour during the last appraisal meeting. Taking some points from your previous interaction, won’t be harmful after all!
We all know that an appraisal meeting is usually an effective tool to give feedback to a candidate on his/her performance. It’s also important to do self-analysis both before and after an appraisal meeting. “After an appraisal, a candidate is eager to find out where he stands among other team members, so that he/she knows their relative performance level. He/she should analyse performance thoroughly post this review in order to improve on all parameters,” suggests Chander Agarwal, joint managing director, TCI.
Agarwal believes that an appraisal meeting is a learning experience for both candidate and an organisation; such meetings provide an opportunity to discuss factors that influenced candidate performance during the period under review. He states, “HR departments also share management’s expectations from the candidate during such meetings, so that they can enhance their performance in the next appraisal cycle. These meetings can also be used for grooming candidates for leadership roles.”
You can assess/measure performance in some of the following ways, as Agarwal points out:
. By doing objective review of his/her performance against preset targets
. By preparing a list of achievements and what couldn’t be achieved during the period under review
. By taking feedback from peers/team members on their performance
. By keeping a track of the overall team performance
. By comparing your performance vis-a-vis performance of others in the function/team, as performance level of others has an impact on your performance.
With your performance varying from year-to-year, it’s practical to think that your appraisal meeting will also have different discussion points; but the basics always remain the same, according to experts. An employee can prepare on these basic talking points and can use some of the learning from his/her past appraisal meeting.

Get every new post delivered to your Inbox.

Join 482 other followers

%d bloggers like this: