doomhz / ganalytics Goto Github PK
View Code? Open in Web Editor NEWGoogle Analaytics API Data import class for PHP.
Home Page: http://dumitruglavan.com/ganalytics-class-access-google-analytics-data-api-with-php/
Google Analaytics API Data import class for PHP.
Home Page: http://dumitruglavan.com/ganalytics-class-access-google-analytics-data-api-with-php/
GAnalytics PHP Class - Query Google Analytics API Data A simple class to import Google Analytics data from your account. How to: <?php // Include the Google Analytics data import class include_once 'GAnalytics/GAnalytics.php'; // Set up your Google Analytics credentials $gaEmail = 'XXXXXX'; $gaPassword = 'XXXXXX'; // Set up a period of time to get data for $statsStartDate = date('Y-m-d', time() - 8 * 24 * 60 *60); //one week ahead $statsEndDate = date('Y-m-d', time() - 1 * 24 * 60 *60); //yesterday // Get and store the query data code from Google Analytics Data Feed Query Explorer // http://code.google.com/apis/analytics/docs/gdata/gdataExplorer.html // // You will set here your own query data url $gaUrl = "https://www.google.com/analytics/feeds/data?" . "ids=ga%XXXXXX&" . "dimensions=ga%3ApagePath" . "&metrics=ga%3Avisits&" . "filters=ga%3ApagePath%3D~anunt%5C%3Fid%3D*&" . "sort=-ga%3Avisits&" . "start-date={$statsStartDate}&" . "end-date={$statsEndDate}&" . "max-results=5"; // Keep your connection data into a config array $config = array('email' => $gaEmail, 'password' => $gaPassword, 'requestUrl' => $gaUrl, ); // Create a new GAnalytics object $ga = new GAnalytics($config); try { // Call the Google Analytics API request in here $gaResult = $ga->call(); // If the call was successful - do your magic in here // You have to parse the Atom Feed XML response and gather you stats // This can be achieved with a SimpleXML tree traversing // or with a preg_match_call() to make your life easier preg_match_all("@<dxp:dimension name='ga:pagePath' value='/anunt\?id=([0-9]{1,})'/>@", $gaResult, $matches); // A dummy data rendering here... var_dump($matches, $matches[1], $gaResult); } catch (Exception $e) { // Log your error here echo "GAnalytics Connection error ({$e->getCode()}): {$e->getMessage()}"; }
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.