compared with
Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (15)

View Page History

{zone-data:milestones}
* Milestone 1: \[DONE\]Create Proposal
* Milestone 2: \[IN PROGRESS\]Create Class Skeletons
* Milestone 3: Code working prototype
* Milestone 4: Working prototype checked into the incubator
{zone-data:class-list}
* Zend_Gdata_Analytics
* Zend_Gdata_Analytics_DataQuery
* Zend_Gdata_Analytics_DataFeed
* Zend_Gdata_Analytics_DataEntry
* Zend_Gdata_Analytics_AccountFeed
* Zend_Gdata_Analytics_AccountEntry
||UC-01||
{code}
require_once 'Zend/Gdata/ClientLogin.php';
require_once 'Zend/Gdata/Analytics.php';

$email = 'somebody@example.com';
$password = 'p455w0rd';

$client = Zend_Gdata_ClientLogin::getHttpClient($email, $password, Zend_Gdata_Analytics::AUTH_SERVICE_NAME);
$service = new Zend_Gdata_Analytics($client);
$feedList = $service->getAccountListFeed();
foreach($feedList as $account){
echo $account->title;
$accounts = $service->getAccountFeed();

$properties = array(
'webPropertyId', 'accountName', 'accountId',
'profileId', 'currency', 'timezone',
'title', 'tableId', 'id', 'updated', 'link'
);

foreach($accounts as $account) {
echo "{$account->title}\n";
foreach($properties as $property) {
echo "\t{$property} = {$account->$property}\n";
}
}
{code}
{code}
$service = new Zend_Gdata_Analytics($client);
$query = $service->getNewAnalyticsQuery(); $service->getDataQuery();
$query->addDimension(Zend_Gdata_Analytics_DataQuery::DIMENSION_USER_DEFINED_VALUE)
->addMetric(Zend_Gdata_Analytics_DataQuery::METRIC_GOAL_1_COMPLETE)
->setStartDate('2009-12-01')
->setEndDate('2009-12-31')
->setOrder(Zend_Gdata_Analytics_DataQuery::METRIC_GOAL_1_COMPLETE, Zend_Gdata_Analytics_DataQuery::ORDER_DESC);
$result = $service->getAnalyticsDataFeed($query);
// ...
{code}

{zone-data:skeletons}
* Milestone 2
||Zend_Gdata_Analytics||
{code}
class Zend_Gdata_Analytics extends Zend_Gdata {

const AUTH_SERVICE_NAME = 'analytics';
const ANALYTICS_FEED_URI = 'http://www.google.com/analytics/feeds';
const ANALYTICS_ACCOUNT_FEED_URI = 'http://www.google.com/analytics/feeds/accounts';

public static $namespaces = array(
array('ga', 'http://schemas.google.com/analytics/2009', 1, 0));

/**
* Create Zend_Gdata_Analytics object
*
* @param Zend_Http_Client $client (optional) The HTTP client to use when
* when communicating with the Google Apps servers.
* @param string $applicationId The identity of the app in the form of Company-AppName-Version
*/
public function __construct($client = null, $applicationId = 'MyCompany-MyApp-1.0');

/**
* Retrieve account feed object
*
* @return Zend_Gdata_Analytics_AccountFeed
*/
public function getAccountFeed();

/**
* Retrieve data feed object
*
* @param mixed $location
* @return Zend_Gdata_Analytics_DataFeed
*/
public function getDataFeed($location);

/**
* Returns a new DataQuery object.
*
* @return Better_Gdata_Analytics_DataQuery
*/
public function newDataQuery();
}
{code}
||Zend_Gdata_Analytics_DataQuery||
{code}
class Zend_Gdata_Analytics_DataQuery extends Zend_Gdata_Query {

const ANALYTICS_FEED_URI = 'http://www.google.com/analytics/feeds/data';

/**
* The default URI used for feeds.
*/
protected $_defaultFeedUri = self::ANALYTICS_FEED_URI;

// D1. Visitor
const DIMENSION_BROWSER = 'ga:browser';
const DIMENSION_BROWSER_VERSION = 'ga:browserVersion';
const DIMENSION_CITY = 'ga:city';
const DIMENSION_CONNECTIONSPEED = 'ga:connectionSpeed';
const DIMENSION_CONTINENT = 'ga:continent';
const DIMENSION_COUNTRY = 'ga:country';
const DIMENSION_DATE = 'ga:date';
const DIMENSION_DAY = 'ga:day';
const DIMENSION_DAYS_SINCE_LAST_VISIT= 'ga:daysSinceLastVisit';
const DIMENSION_FLASH_VERSION = 'ga:flashVersion';
const DIMENSION_HOSTNAME = 'ga:hostname';
const DIMENSION_HOUR = 'ga:hour';
const DIMENSION_JAVA_ENABLED= 'ga:javaEnabled';
const DIMENSION_LANGUAGE= 'ga:language';
const DIMENSION_LATITUDE = 'ga:latitude';
const DIMENSION_LONGITUDE = 'ga:longitude';
const DIMENSION_MONTH = 'ga:month';
const DIMENSION_NETWORK_DOMAIN = 'ga:networkDomain';
const DIMENSION_NETWORK_LOCATION = 'ga:networkLocation';
const DIMENSION_OPERATING_SYSTEM = 'ga:operatingSystem';
const DIMENSION_OPERATING_SYSTEM_VERSION = 'ga:operatingSystemVersion';
const DIMENSION_PAGE_DEPTH = 'ga:pageDepth';
const DIMENSION_REGION = 'ga:region';
const DIMENSION_SCREEN_COLORS= 'ga:screenColors';
const DIMENSION_SCREEN_RESOLUTION = 'ga:screenResolution';
const DIMENSION_SUB_CONTINENT = 'ga:subContinent';
const DIMENSION_USER_DEFINED_VALUE = 'ga:userDefinedValue';
const DIMENSION_VISIT_COUNT = 'ga:visitCount';
const DIMENSION_VISIT_LENGTH = 'ga:visitLength';
const DIMENSION_VISITOR_TYPE = 'ga:visitorType';
const DIMENSION_WEEK = 'ga:week';
const DIMENSION_YEAR = 'ga:year';

// D2. Campaign
const DIMENSION_AD_CONTENT = 'ga:adContent';
const DIMENSION_AD_GROUP = 'ga:adGroup';
const DIMENSION_AD_SLOT = 'ga:adSlot';
const DIMENSION_AD_SLOT_POSITION = 'ga:adSlotPosition';
const DIMENSION_CAMPAIGN = 'ga:campaign';
const DIMENSION_KEYWORD = 'ga:keyword';
const DIMENSION_MEDIUM = 'ga:medium';
const DIMENSION_REFERRAL_PATH = 'ga:referralPath';
const DIMENSION_SOURCE = 'ga:source';

// D3. Content
const DIMENSION_EXIT_PAGE_PATH = 'ga:exitPagePath';
const DIMENSION_LANDING_PAGE_PATH = 'ga:landingPagePath';
const DIMENSION_PAGE_PATH = 'ga:pagePath';
const DIMENSION_PAGE_TITLE = 'ga:pageTitle';
const DIMENSION_SECOND_PAGE_PATH = 'ga:secondPagePath';

// D4. Ecommerce
const DIMENSION_AFFILIATION = 'ga:affiliation';
const DIMENSION_DAYS_TO_TRANSACTION = 'ga:daysToTransaction';
const DIMENSION_PRODUCT_CATEGORY = 'ga:productCategory';
const DIMENSION_PRODUCT_NAME = 'ga:productName';
const DIMENSION_PRODUCT_SKU = 'ga:productSku';
const DIMENSION_TRANSACTION_ID = 'ga:transactionId';
const DIMENSION_VISITS_TO_TRANSACTION = 'ga:visitsToTransaction';

// D5. Internal Search
const DIMENSION_SEARCH_CATEGORY = 'ga:searchCategory';
const DIMENSION_SEARCH_DESTINATION_PAGE = 'ga:searchDestinationPage';
const DIMENSION_SEARCH_KEYWORD = 'ga:searchKeyword';
const DIMENSION_SEARCH_KEYWORD_REFINEMENT = 'ga:searchKeywordRefinement';
const DIMENSION_SEARCH_START_PAGE = 'ga:searchStartPage';
const DIMENSION_SEARCH_USED = 'ga:searchUsed';

// D6. Navigation
const DIMENSION_NEXT_PAGE_PATH = 'ga:nextPagePath';
const DIMENSION_PREV_PAGE_PATH= 'ga:previousPagePath';

// D7. Events
const DIMENSION_EVENT_CATEGORY = 'ga:eventCategory';
const DIMENSION_EVENT_ACTION = 'ga:eventAction';
const DIMENSION_EVENT_LABEL = 'ga:eventLabel';

// D8. Custon Variables
const DIMENSION_CUSTOM_VAR_NAME_1 = 'ga:customVarName1';
const DIMENSION_CUSTOM_VAR_NAME_2 = 'ga:customVarName2';
const DIMENSION_CUSTOM_VAR_NAME_3 = 'ga:customVarName3';
const DIMENSION_CUSTOM_VAR_NAME_4 = 'ga:customVarName4';
const DIMENSION_CUSTOM_VAR_NAME_5 = 'ga:customVarName5';
const DIMENSION_CUSTOM_VAR_VALUE_1 = 'ga:customVarValue1';
const DIMENSION_CUSTOM_VAR_VALUE_2 = 'ga:customVarValue2';
const DIMENSION_CUSTOM_VAR_VALUE_3 = 'ga:customVarValue3';
const DIMENSION_CUSTOM_VAR_VALUE_4 = 'ga:customVarValue4';
const DIMENSION_CUSTOM_VAR_VALUE_5 = 'ga:customVarValue5';

// M1. Visitor
const METRIC_BOUNCES = 'ga:bounces';
const METRIC_ENTRANCES = 'ga:entrances';
const METRIC_EXITS = 'ga:exits';
const METRIC_NEW_VISITS = 'ga:newVisits';
const METRIC_PAGEVIEWS = 'ga:pageviews';
const METRIC_TIME_ON_PAGE = 'ga:timeOnPage';
const METRIC_TIME_ON_SITE = 'ga:timeOnSite';
const METRIC_VISITORS = 'ga:visitors';
const METRIC_VISITS = 'ga:visits';

// M2. Campaign
const METRIC_AD_CLICKS = 'ga:adClicks';
const METRIC_AD_COST = 'ga:adCost';
const METRIC_CPC = 'ga:CPC';
const METRIC_CPM = 'ga:CPM';
const METRIC_CTR = 'ga:CTR';
const METRIC_IMPRESSIONS = 'ga:impressions';

// M3. Content
const METRIC_UNIQUE_PAGEVIEWS = 'ga:uniquePageviews';

// M4. Ecommerce
const METRIC_ITEM_REVENUE = 'ga:itemRevenue';
const METRIC_ITEM_QUANTITY = 'ga:itemQuantity';
const METRIC_TRANSACTIONS = 'ga:transactions';
const METRIC_TRANSACTION_REVENUE = 'ga:transactionRevenue';
const METRIC_TRANSACTION_SHIPPING = 'ga:transactionShipping';
const METRIC_TRANSACTION_TAX = 'ga:transactionTax';
const METRIC_UNIQUE_PURCHASES = 'ga:uniquePurchases';

// M5. Internal Search
const METRIC_SEARCH_DEPTH = 'ga:searchDepth';
const METRIC_SEARCH_DURATION = 'ga:searchDuration';
const METRIC_SEARCH_EXITS = 'ga:searchExits';
const METRIC_SEARCH_REFINEMENTS = 'ga:searchRefinements';
const METRIC_SEARCH_UNIQUES = 'ga:searchUniques';
const METRIC_SEARCH_VISIT = 'ga:searchVisits';

// M6. Goals
const METRIC_GOAL_COMPLETIONS_ALL = 'ga:goalCompletionsAll';
const METRIC_GOAL_STARTS_ALL = 'ga:goalStartsAll';
const METRIC_GOAL_VALUE_ALL = 'ga:goalValueAll';
// TODO goals 1-20
const METRIC_GOAL_1_COMPLETION = 'ga:goal1Completions';
const METRIC_GOAL_1_STARTS = 'ga:goal1Starts';
const METRIC_GOAL_1_VALUE = 'ga:goal1Value';

// M7. Events
const METRIC_TOTAL_EVENTS = 'ga:totalEvents';
const METRIC_UNIQUE_EVENTS = 'ga:uniqueEvents';
const METRIC_EVENT_VALUE = 'ga:eventValue';

/**
* @var string
*/
protected $_profileId;
/**
* @var array
*/
protected $_dimensions = array();
/**
* @var array
*/
protected $_metrics = array();

/**
* @param string $id
* @return Zend_Gdata_Analytics_DataQuery
*/
public function setProfileId($id);

/**
* @return string
*/
public function getProfileId();

/**
* @param string $dimension
* @return Zend_Gdata_Analytics_DataQuery
*/
public function addDimension($dimension);

/**
* @param string $metric
* @return Zend_Gdata_Analytics_DataQuery
*/
public function addMetric($metric);

/**
* @return array
*/
public function getDimensions();

/**
* @return array
*/
public function getMetrics();

/**
* @param string $dimension
* @return Zend_Gdata_Analytics_DataQuery
*/
public function removeDimension($dimension);

/**
* @param string $metric
* @return Zend_Gdata_Analytics_DataQuery
*/
public function removeMetric($metric);

/**
* @param string $value
* @return Zend_Gdata_Analytics_DataQuery
*/
public function setStartDate($date);

/**
* @param string $value
* @return Zend_Gdata_Analytics_DataQuery
*/
public function setEndDate($date);

/**
* @param string $value
* @return Zend_Gdata_Analytics_DataQuery
*/
public function setFilter($value);

/**
* @param string $sort
* @return Zend_Gdata_Analytics_DataQuery
*/
public function setSort($sort);

/**
* @return string url
*/
public function getQueryUrl();
}
{code}
{zone-data}