|
<?php |
|
|
|
// |
|
// Open Web Analytics - An Open Source Web Analytics Framework |
|
// |
|
// Copyright 2006 Peter Adams. All rights reserved. |
|
// |
|
// Licensed under GPL v2.0 http://www.gnu.org/copyleft/gpl.html |
|
// |
|
// Unless required by applicable law or agreed to in writing, software |
|
// distributed under the License is distributed on an "AS IS" BASIS, |
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
// See the License for the specific language governing permissions and |
|
// limitations under the License. |
|
// |
|
// $Id$ |
|
// |
|
|
|
require_once(OWA_BASE_DIR.'/owa_module.php'); |
|
|
|
/** |
|
* Base Package Module |
|
* |
|
* @author Peter Adams <peter@openwebanalytics.com> |
|
* @copyright Copyright © 2006 Peter Adams <peter@openwebanalytics.com> |
|
* @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 |
|
* @category owa |
|
* @package owa |
|
* @version $Revision$ |
|
* @since owa 1.0.0 |
|
*/ |
|
|
|
class owa_baseModule extends owa_module { |
|
|
|
/** |
|
* Constructor |
|
* |
|
*/ |
|
function __construct() { |
|
|
|
$this->name = 'base'; |
|
$this->display_name = 'Open Web Analytics'; |
|
$this->group = 'Base'; |
|
$this->author = 'Peter Adams'; |
|
$this->version = 6; |
|
$this->description = 'Base functionality for OWA.'; |
|
$this->config_required = false; |
|
$this->required_schema_version = 6; |
|
|
|
/** |
|
* Register Filters |
|
* |
|
* The following lines register filter methods. |
|
*/ |
|
$this->registerFilter('operating_system', $this, 'determineOperatingSystem', 0); |
|
$this->registerFilter('ip_address', $this, 'setIp', 0); |
|
$this->registerFilter('full_host', $this, 'resolveHost', 0); |
|
$this->registerFilter('host', $this, 'getHostDomain', 0); |
|
$this->registerFilter('attributed_campaign', $this, 'attributeCampaign', 10); |
|
$this->registerFilter('geolocation', 'hostip', 'get_location', 10, 'classes'); |
|
//Clean Query Strings |
|
if (owa_coreAPI::getSetting('base', 'clean_query_string')) { |
|
$this->registerFilter('page_url', $this, 'makeUrlCanonical',0); |
|
$this->registerFilter('prior_page', $this, 'makeUrlCanonical',0); |
|
$this->registerFilter('target_url', $this, 'makeUrlCanonical',0); |
|
} |
|
// event procesing daemon jobs |
|
$this->registerBackgroundJob('process_event_queue', 'cli.php cmd=processEventQueue', owa_coreAPI::getSetting('base', 'processQueuesJobSchedule'), 10); |
|
|
|
/** |
|
* Register Service Implementations |
|
* |
|
* The following lines register various service implementations. |
|
*/ |
|
|
|
/** |
|
* Register Metrics |
|
* |
|
* The following lines register various data metrics. |
|
*/ |
|
$this->registerMetric('pageViews', 'base.pageViews'); |
|
$this->registerMetric('pageViews', 'base.pageViewsFromSessionFact'); |
|
$this->registerMetric('uniqueVisitors', 'base.uniqueVisitors'); |
|
$this->registerMetric('visits', 'base.visits'); |
|
$this->registerMetric('visits', 'base.visitsFromRequestFact'); |
|
$this->registerMetric('visitors', 'base.visitors'); |
|
$this->registerMetric('visitors', 'base.visitorsFromRequestFact'); |
|
$this->registerMetric('newVisitors', 'base.newVisitors'); |
|
$this->registerMetric('repeatVisitors', 'base.repeatVisitors'); |
|
$this->registerMetric('bounces', 'base.bounces'); |
|
$this->registerMetric('visitDuration', 'base.visitDuration'); |
|
$this->registerMetric('uniquePageViews', 'base.uniquePageViews'); |
|
$this->registerMetric('bounceRate', 'base.bounceRate'); |
|
$this->registerMetric('pagesPerVisit', 'base.pagesPerVisit'); |
|
$this->registerMetric('actions', 'base.actions'); |
|
$this->registerMetric('uniqueActions', 'base.uniqueActions'); |
|
$this->registerMetric('actionsValue', 'base.actionsValue'); |
|
//$this->registerMetric('actionsPerVisit', 'base.actionsPerVisit'); |
|
$this->registerMetric('feedRequests', 'base.feedRequests'); |
|
$this->registerMetric('feedReaders', 'base.feedReaders'); |
|
$this->registerMetric('feedSubscriptions', 'base.feedSubscriptions'); |
|
|
|
// goals |
|
$gcount = owa_coreAPI::getSetting('base', 'numGoals'); |
|
for ($num = 1; $num <= $gcount;$num++) { |
|
$params = array('goal_number' => $num); |
|
|
|
$metric_name = 'goal'.$num.'Completions'; |
|
$this->registerMetric($metric_name, 'base.goalNCompletions', $params); |
|
|
|
$metric_name = 'goal'.$num.'Starts'; |
|
$this->registerMetric($metric_name, 'base.goalNStarts', $params); |
|
|
|
$metric_name = 'goal'.$num.'Value'; |
|
$this->registerMetric($metric_name, 'base.goalNValue', $params); |
|
} |
|
|
|
$this->registerMetric('goalCompletionsAll', 'base.goalCompletionsAll'); |
|
$this->registerMetric('goalStartsAll', 'base.goalStartsAll'); |
|
$this->registerMetric('goalValueAll', 'base.goalValueAll'); |
|
$this->registerMetric('goalConversionRateAll', 'base.goalConversionRateAll'); |
|
$this->registerMetric('goalAbandonRateAll', 'base.goalAbandonRateAll'); |
|
|
|
// ecommerce metrics |
|
$this->registerMetric('lineItemQuantity', 'base.lineItemQuantity'); |
|
$this->registerMetric('lineItemQuantity', 'base.lineItemQuantityFromSessionFact'); |
|
$this->registerMetric('lineItemRevenue', 'base.lineItemRevenue'); |
|
$this->registerMetric('lineItemRevenue', 'base.lineItemRevenueFromSessionFact'); |
|
$this->registerMetric('transactions', 'base.transactions'); |
|
$this->registerMetric('transactions', 'base.transactionsFromSessionFact'); |
|
$this->registerMetric('transactionRevenue', 'base.transactionRevenue'); |
|
$this->registerMetric('transactionRevenue', 'base.transactionRevenueFromSessionFact'); |
|
$this->registerMetric('taxRevenue', 'base.taxRevenue'); |
|
$this->registerMetric('taxRevenue', 'base.taxRevenueFromSessionFact'); |
|
$this->registerMetric('shippingRevenue', 'base.shippingRevenue'); |
|
$this->registerMetric('shippingRevenue', 'base.shippingRevenueFromSessionFact'); |
|
$this->registerMetric('uniqueLineItems', 'base.uniqueLineItems'); |
|
$this->registerMetric('uniqueLineItems', 'base.uniqueLineItemsFromSessionFact'); |
|
$this->registerMetric('revenuePerTransaction', 'base.revenuePerTransaction'); |
|
$this->registerMetric('revenuePerVisit', 'base.revenuePerVisit'); |
|
$this->registerMetric('ecommerceConversionRate', 'base.ecommerceConversionRate'); |
|
$this->registerMetric('domClicks', 'base.domClicks'); |
|
/** |
|
* Register Dimensions |
|
* |
|
* The following lines register various data dimensions. |
|
*/ |
|
$this->registerDimension('browserVersion', 'base.ua', 'browser', 'Browser Version', 'visitor', 'The browser version of the visitor.'); |
|
$this->registerDimension('browserType', 'base.ua', 'browser_type', 'Browser Type', 'visitor', 'The browser type of the visitor.'); |
|
$this->registerDimension('osType', 'base.os', 'name', 'Operating System', 'visitor', 'The operating System of the visitor.'); |
|
$this->registerDimension('ipAddress', 'base.host', 'ip_address', 'IP Address', 'visitor', 'The IP address of the visitor.'); |
|
$this->registerDimension('hostName', 'base.host', 'full_host', 'Host Name', 'visitor', 'The host name used by the visitor.'); |
|
$this->registerDimension('city', 'base.location_dim', 'city', 'City', 'visitor', 'The city of the visitor.'); |
|
$this->registerDimension('country', 'base.location_dim', 'country', 'Country', 'visitor', 'The country of the visitor.'); |
|
$this->registerDimension('latitude', 'base.location_dim', 'latitude', 'Latitude', 'visitor', 'The latitude of the visitor.'); |
|
$this->registerDimension('longitude', 'base.location_dim', 'longitude', 'Longitude', 'visitor', 'The longitude of the visitor.'); |
|
$this->registerDimension('countryCode', 'base.location_dim', 'country_code', 'Country Code', 'visitor', 'The ISO country code of the visitor.'); |
|
$this->registerDimension('stateRegion', 'base.location_dim', 'state', 'State/Region', 'visitor', 'The state or region of the visitor.'); |
|
|
|
$this->registerDimension('timeSinceLastVisit', 'base.session', 'time_sinse_priorsession', 'Time Since Last Visit', 'visitor', 'The time since the last visit.', '', true); |
|
$this->registerDimension('isRepeatVisitor', 'base.session', 'is_repeat_visitor', 'Repeat Visitor', 'visitor', 'Repeat Site Visitor.', '', true); |
|
$this->registerDimension('isNewVisitor', 'base.session', 'is_new_visitor', 'New Visitor', 'visitor', 'New Site Visitor.', '', true); |
|
$this->registerDimension('language', 'base.session', 'language', 'Language', 'visit', 'The language of the visit.', '', true); |
|
$this->registerDimension('language', 'base.request', 'language', 'Language', 'visit', 'The language of the visit.', '', true); |
|
// campaign related |
|
$this->registerDimension('medium', 'base.session', 'medium', 'Medium', 'visit', 'The medium of channel of visit.', '', true); |
|
$this->registerDimension('latestAttributions', 'base.session', 'latest_attributions', 'Latest Attributions', 'visit', 'The latest campaign attributions.', '', true); |
|
$this->registerDimension('source', 'base.source_dim', 'source_domain', 'Source', 'visit', 'The traffic source of the visit.'); |
|
$this->registerDimension('campaign', 'base.campaign_dim', 'name', 'Campaign', 'visit', 'The campaign that originated the visit.'); |
|
$this->registerDimension('ad', 'base.ad_dim', 'name', 'Ad', 'visit', 'The name of the ad that originated the visit.'); |
|
$this->registerDimension('adType', 'base.ad_dim', 'type', 'Ad Type', 'visit', 'The type of ad that originated the visit.'); |
|
|
|
$this->registerDimension('siteDomain', 'base.site', 'domain', 'Site Domain', 'visit', 'The domain of the site.'); |
|
$this->registerDimension('siteName', 'base.site', 'name', 'Site Name', 'visit', 'The name of the site.'); |
|
$this->registerDimension('siteId', 'base.site', 'site_id', 'Site ID', 'visit', 'The ID of the site.'); |
|
$this->registerDimension('userName', 'base.visitor', 'user_name', 'User Name', 'visitor', 'The name or ID of the user.'); |
|
$this->registerDimension('userEmail', 'base.visitor', 'user_email', 'Email Address', 'visitor', 'The email address of the user.'); |
|
|
|
// Date and time oriented dimensions |
|
$this->registerDimension('date', 'base.session', 'yyyymmdd', 'Date', 'visit', 'The date.', '', true, 'yyyymmdd'); |
|
$this->registerDimension('day', 'base.session', 'day', 'Day', 'visit', 'The day.', '', true); |
|
$this->registerDimension('month', 'base.session', 'month', 'Month', 'visit', 'The month.', '', true); |
|
$this->registerDimension('year', 'base.session', 'year', 'Year', 'visit', 'The year.', '', true); |
|
$this->registerDimension('dayofweek', 'base.session', 'dayofweek', 'Day of Week', 'visit', 'The day of the week.', '', true); |
|
$this->registerDimension('dayofyear', 'base.session', 'dayofyear', 'Day of Year', 'visit', 'The day of the year.', '', true); |
|
$this->registerDimension('weekofyear', 'base.session', 'weekofyear', 'Week of Year', 'visit', 'The week of the year.', '', true); |
|
$this->registerDimension('siteId', 'base.session', 'site_id', 'Site ID', 'visit', 'The ID of the the web site.', '', true); |
|
$this->registerDimension('daysSinceLastVisit', 'base.session', 'days_since_prior_session', 'Days Since Last Visit', 'visit', 'The number of days since the last visit.', '', true); |
|
$this->registerDimension('daysSinceFirstVisit', 'base.session', 'days_since_first_session', 'Days Since First Visit', 'visit', 'The number of days since the first visit of the user.', '', true); |
|
|
|
$this->registerDimension('priorVisitCount', 'base.session', 'num_prior_sessions', 'Prior Visits', 'visit', 'The number of prior visits, excluding the current one.', '', true); |
|
|
|
$this->registerDimension('priorVisitCount', 'base.request', 'num_prior_sessions', 'Prior Visits', 'visit', 'The number of prior visits, excluding the current one.', '', true); |
|
|
|
$this->registerDimension('date', 'base.request', 'yyyymmdd', 'Date', 'visit', 'The date.', '', true, 'yyyymmdd'); |
|
$this->registerDimension('day', 'base.request', 'day', 'Day', 'visit', 'The day.', '', true); |
|
$this->registerDimension('month', 'base.request', 'month', 'Month', 'visit', 'The month.', '', true); |
|
$this->registerDimension('year', 'base.request', 'year', 'Year', 'visit', 'The year.', '', true); |
|
$this->registerDimension('dayofweek', 'base.request', 'dayofweek', 'Day of Week', 'visit', 'The day of the week.', '', true); |
|
$this->registerDimension('dayofyear', 'base.request', 'dayofyear', 'Day of Year', 'visit', 'The day of the year.', '', true); |
|
$this->registerDimension('weekofyear', 'base.request', 'weekofyear', 'Week of Year', 'visit', 'The week of the year.', '', true); |
|
$this->registerDimension('siteId', 'base.request', 'site_id', 'Site ID', 'visit', 'The ID of the the web site.', '', true); |
|
|
|
$this->registerDimension('actionName', 'base.action_fact', 'action_name', 'Action Name', 'actions', 'The name of the action.', '', true); |
|
$this->registerDimension('actionGroup', 'base.action_fact', 'action_group', 'Action Group', 'actions', 'The group that an action belongs to.', '', true); |
|
$this->registerDimension('actionLabel', 'base.action_fact', 'action_label', 'Action Label', 'actions', 'The label associated with an action.', '', true); |
|
$this->registerDimension('date', 'base.action_fact', 'yyyymmdd', 'Date', 'action', 'The date.', '', true, 'yyyymmdd'); |
|
$this->registerDimension('siteId', 'base.acton_fact', 'site_id', 'Site ID', 'visit', 'The ID of the the web site.', '', true); |
|
|
|
// visit |
|
$this->registerDimension('entryPageUrl', 'base.document', 'url', 'Entry Page URL', 'visit', 'The URL of the entry page.', 'first_page_id'); |
|
$this->registerDimension('entryPagePath', 'base.document', 'uri', 'Entry Page Path', 'visit', 'The URI of the entry page.', 'first_page_id'); |
|
$this->registerDimension('entryPageTitle', 'base.document', 'page_title', 'Entry Page Title', 'visit', 'The title of the entry page.', 'first_page_id'); |
|
$this->registerDimension('entryPageType', 'base.document', 'page_type', 'Entry Page Type', 'visit', 'The page type of the entry page.', 'first_page_id'); |
|
$this->registerDimension('exitPageUrl', 'base.document', 'url', 'Exit Page URL', 'visit', 'The URL of the exit page.', 'last_page_id'); |
|
$this->registerDimension('exitPagePath', 'base.document', 'uri', 'Exit Page Path', 'visit', 'The URI of the exit page.', 'last_page_id'); |
|
$this->registerDimension('exitPageTitle', 'base.document', 'page_title', 'Exit Page Title', 'visit', 'The title of the exit page.', 'last_page_id'); |
|
$this->registerDimension('exitPageType', 'base.document', 'page_type', 'Exit Page Type', 'visit', 'The page type of the exit page.', 'last_page_id'); |
|
$this->registerDimension('priorPageUrl', 'base.document', 'url', 'Prior Page URL', 'visit', 'The URL of the prior page.', 'prior_document_id'); |
|
$this->registerDimension('priorPagePath', 'base.document', 'uri', 'Prior Page Path', 'visit', 'The URI of the prior page.', 'prior_document_id'); |
|
$this->registerDimension('priorPageTitle', 'base.document', 'page_title', 'Prior Page Title', 'visit', 'The title of the prior page.', 'prior_document_id'); |
|
$this->registerDimension('priorPageType', 'base.document', 'page_type', 'Prior Page Type', 'visit', 'The page type of the prior page.', 'prior_document_id'); |
|
|
|
// traffic sources |
|
$this->registerDimension('referralPageUrl', 'base.referer', 'url', 'Referral Page URL', 'traffic sources', 'The url of the referring web page.'); |
|
$this->registerDimension('referralPageTitle', 'base.referer', 'page_title', 'Referral Page Title', 'traffic sources', 'The title of the referring web page.'); |
|
$this->registerDimension('referralSearchTerms', 'base.search_term_dim', 'terms', 'Search Terms', 'traffic sources', 'The referring search terms.', 'referring_search_term_id'); |
|
$this->registerDimension('referralLinkText', 'base.referer', 'refering_anchortext', 'Referral Link Text', 'traffic sources', 'The text of the referring link.'); |
|
$this->registerDimension('isSearchEngine', 'base.referer', 'is_searchengine', 'Search Engine', 'traffic sources', 'Is traffic source a search engine.'); |
|
$this->registerDimension('referralWebSite', 'base.referer', 'site', 'Referral Web Site', 'traffic sources', 'The full domain of the referring web site.'); |
|
|
|
// content |
|
$this->registerDimension('pageUrl', 'base.document', 'url', 'Page URL', 'content', 'The URL of the web page.', 'document_id'); |
|
$this->registerDimension('pagePath', 'base.document', 'uri', 'Page Path', 'content', 'The path of the web page.', 'document_id'); |
|
$this->registerDimension('pageTitle', 'base.document', 'page_title', 'Page Title', 'content', 'The title of the web page.', 'document_id'); |
|
$this->registerDimension('pageType', 'base.document', 'page_type', 'Page Type', 'content', 'The page type of the web page.', 'document_id'); |
|
|
|
// feeds |
|
$this->registerDimension('date', 'base.feed_request', 'yyyymmdd', 'Date', 'date', 'The date.', '', true, 'yyyymmdd'); |
|
$this->registerDimension('day', 'base.feed_request', 'day', 'Day', 'date', 'The day.', '', true); |
|
$this->registerDimension('month', 'base.feed_request', 'month', 'Month', 'date', 'The month.', '', true); |
|
$this->registerDimension('year', 'base.feed_request', 'year', 'Year', 'date', 'The year.', '', true); |
|
$this->registerDimension('dayofweek', 'base.feed_request', 'dayofweek', 'Day of Week', 'date', 'The day of the week.', '', true); |
|
$this->registerDimension('dayofyear', 'base.feed_request', 'dayofyear', 'Day of Year', 'date', 'The day of the year.', '', true); |
|
$this->registerDimension('weekofyear', 'base.feed_request', 'weekofyear', 'Week of Year', 'date', 'The week of the year.', '', true); |
|
$this->registerDimension('feedType', 'base.feed_request', 'feed_format', 'Feed Type', 'feed', 'The type or format of the feed.', '', true); |
|
$this->registerDimension('siteId', 'base.feed_request', 'site_id', 'Site ID', 'request', 'The ID of the the web site.', '', true); |
|
|
|
//clicks |
|
$this->registerDimension('date', 'base.click', 'yyyymmdd', 'Date', 'visit', 'The date.', '', true, 'yyyymmdd'); |
|
// IDs |
|
$this->registerDimension('visitorId', 'base.visitor', 'id', 'Visitor ID', 'visitor', 'The ID of the visitor.'); |
|
$this->registerDimension('sessionId', 'base.session', 'id', 'Session ID', 'visit', 'The ID of the session/visit.'); |
|
|
|
$this->registerDimension('daysToTransaction', 'base.commerce_transaction_fact', 'days_since_first_session', 'Days To Purchase', 'ecommerce', 'The number of days since the first visit and an e-commerce transaction.', '', true); |
|
$this->registerDimension('visitsToTransaction', 'base.commerce_transaction_fact', 'num_prior_sessions', 'Visits To Purchase', 'ecommerce', 'The number of visits prior to an e-commerce transaction.', '', true); |
|
|
|
// productName |
|
$this->registerDimension( |
|
'productName', |
|
'base.commerce_line_item_fact', |
|
'product_name', |
|
'Product Name', |
|
'ecommerce', |
|
'The name of the product purchased.', |