{"id":15169768,"url":"https://github.com/ommu/ext-gapi","last_synced_at":"2025-10-01T02:31:51.731Z","repository":{"id":57031288,"uuid":"91058716","full_name":"ommu/ext-gapi","owner":"ommu","description":"GA:PI() - Google Analytics PHP Interface for Ommu Platform","archived":false,"fork":true,"pushed_at":"2023-12-10T10:27:39.000Z","size":68,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-09-18T22:33:17.357Z","etag":null,"topics":["google-analytics","ommu-extension","php-interface","yii","yii2"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"erebusnz/gapi-google-analytics-php-interface","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ommu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-12T06:27:32.000Z","updated_at":"2023-12-10T10:27:53.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/ommu/ext-gapi","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ommu%2Fext-gapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ommu%2Fext-gapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ommu%2Fext-gapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ommu%2Fext-gapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ommu","download_url":"https://codeload.github.com/ommu/ext-gapi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219866483,"owners_count":16554235,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["google-analytics","ommu-extension","php-interface","yii","yii2"],"created_at":"2024-09-27T07:22:20.811Z","updated_at":"2025-10-01T02:31:46.459Z","avatar_url":"https://github.com/ommu.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GAPI now has OAuth2 support #\r\n\r\n**GAPI is now at version 2.0** - This version has full OAuth2 and V3 authentication support.\r\n\r\nDevelopment is complete on the Google Analytics filter control. You can now filter your results using a simple GAPI filter string, for example:\r\n\r\n```\r\n$filter = 'country == United States \u0026\u0026 browser == Firefox || browser == Chrome';\r\n```\r\n\r\nYou can create simple query strings that represent the logic Google Analytics requires, but it is abstracted enough to be more readable and easier to work with.\r\n\r\nDownload the latest [gapi.class.php](https://github.com/erebusnz/gapi-google-analytics-php-interface) and try out the filter control with the example.filter.php. Read more about the [GAPI Filter Control](https://github.com/erebusnz/gapi-google-analytics-php-interface/blob/wiki/UsingFilterControl.md).\r\n\r\n## Features: ##\r\n\r\n  * Supports CURL and fopen HTTP access methods, with autodetection\r\n  * PHP arrays for Google Analytics metrics and dimensions\r\n  * Account data object mapping - get methods for parameters\r\n  * Report data object mapping - get methods for metrics and parameters\r\n  * Easy filtering, use a GAPI query language for Google Analytics filters\r\n  * Full PHP5 Object Oriented code, ready for use in your PHP application\r\n\r\nGAPI (said 'g,a,p,i') is the Google Analytics PHP5 Interface.\r\n\r\nNeed google analytics interface in your OO PHP5 project?\r\n\r\nYou might be running symfony, zend framework, cakePHP and need a good object-oriented interface to get those stats. This class gives a good clean class based interface.\r\n\r\n## Use is as simple as: ##\r\n\r\n```\r\n$ga = new gapi('XXXX@developer.gserviceaccount.com','oauthkeyfile.p12');\r\n\r\n$ga-\u003erequestReportData(145141242,array('browser','browserVersion'),array('pageviews','visits'));\r\n\r\nforeach($ga-\u003egetResults() as $result)\r\n{\r\n  echo '\u003cstrong\u003e'.$result.'\u003c/strong\u003e\u003cbr /\u003e';\r\n  echo 'Pageviews: ' . $result-\u003egetPageviews() . ' ';\r\n  echo 'Visits: ' . $result-\u003egetVisits() . '\u003cbr /\u003e';\r\n}\r\n\r\necho '\u003cp\u003eTotal pageviews: ' . $ga-\u003egetPageviews() . ' total visits: ' . $ga-\u003egetVisits() . '\u003c/p\u003e';\r\n```\r\n\r\nThis project was inspired by the use of Doctrine and Propel ORM interfaces for PHP. Dealing with complex data should be easy!\r\n\r\n## Access metrics and dimensions using magic get methods ##\r\n\r\nWith GAPI, when data is returned from Google it is automatically converted into a native PHP object, with an interface to allow the 'get' the value of any dimesion or metric.\r\n\r\nFor example, if you request the metric 'uniquePageviews' and the dimension 'pagePath' you can do the following:\r\n\r\n```\r\nforeach($ga-\u003egetResults() as $result)\r\n{\r\n  echo $result-\u003egetUniquePageviews();\r\n  echo $result-\u003egetPagePath();\r\n}\r\n```\r\n\r\n## Instructions for setting up a Google service account for use with GAPI\r\n\r\nGAPI (because now Google Analytics API only supports OAuth2) will require you to create a 'service account' and then download a .P12 file to upload to your application.\r\n\r\n  1. Create a [Google Developers project](https://console.developers.google.com/project)\r\n  2. Create service account under this project, [see instructions](https://developers.google.com/identity/protocols/OAuth2ServiceAccount#creatinganaccount)\r\n  3. Download the .p12 file for this service account, upload to the same folder as **gapi.class.php**\r\n  4. Enable 'analytics API' in the [Google Developers console]((https://console.developers.google.com/project))\r\n  5. In Google Analytics *Administration \u003e User Management*, give the service account 'Read and Analyse' permissions on the analytics accounts you want to access\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fommu%2Fext-gapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fommu%2Fext-gapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fommu%2Fext-gapi/lists"}