diff options
author | diosmosis <benaka.moorthi@gmail.com> | 2013-02-10 09:24:18 +0400 |
---|---|---|
committer | diosmosis <benaka.moorthi@gmail.com> | 2013-02-10 09:24:18 +0400 |
commit | ac59017af362e0f1069722df1677f31ac49a3707 (patch) | |
tree | 28517a9a1a7def172e6e44011b74e856c258c23e | |
parent | 2ee4124dd67187bb04b17b872a555bb10e2ac712 (diff) |
Fixes #3232, add ability to discard URL fragments when tracking for all websites or for just some websites.
17 files changed, 258 insertions, 39 deletions
diff --git a/core/Db/Schema/Myisam.php b/core/Db/Schema/Myisam.php index fc06c61ff1..813366de4a 100644 --- a/core/Db/Schema/Myisam.php +++ b/core/Db/Schema/Myisam.php @@ -90,6 +90,7 @@ class Piwik_Db_Schema_Myisam implements Piwik_Db_Schema_Interface excluded_parameters TEXT NOT NULL, excluded_user_agents TEXT NOT NULL, `group` VARCHAR(250) NOT NULL, + keep_url_fragment TINYINT NOT NULL DEFAULT 0, PRIMARY KEY(idsite) ) DEFAULT CHARSET=utf8 ", diff --git a/core/Tracker/Action.php b/core/Tracker/Action.php index 277acf5642..fde033de76 100644 --- a/core/Tracker/Action.php +++ b/core/Tracker/Action.php @@ -280,9 +280,12 @@ class Piwik_Tracker_Action implements Piwik_Tracker_Action_Interface * and deal ith the hash tag on incoming URLs based on website setting. * * @param $parsedUrl + * @param $idSite int|false The site ID of the current visit. This parameter is + * only used by the tracker to see if we should remove + * the URL fragment for this site. * @return array */ - static public function cleanupHostAndHashTag($parsedUrl) + static public function cleanupHostAndHashTag($parsedUrl, $idSite = false) { if(empty($parsedUrl)) { @@ -295,26 +298,55 @@ class Piwik_Tracker_Action implements Piwik_Tracker_Action_Interface if(!empty($parsedUrl['fragment'])) { - $parsedUrl['fragment'] = self::processUrlFragment($parsedUrl['fragment']); + $parsedUrl['fragment'] = self::processUrlFragment($parsedUrl['fragment'], $idSite); } return $parsedUrl; } - public static function processUrlFragment($urlFragment) + /** + * Cleans and/or removes the URL fragment of a URL. + * + * @param $urlFragment string The URL fragment to process. + * @param $idSite int|false If not false, this function will check if URL fragments + * should be removed for the site w/ this ID and if so, + * the returned processed fragment will be empty. + * @return string The processed URL fragment. + */ + public static function processUrlFragment($urlFragment, $idSite = false) { - //TOOD implement, read setting for this site -// return ''; http://dev.piwik.org/trac/ticket/3232 - - - // Remove trailing Hash tag in ?query#hash# - if(substr($urlFragment, -1) == '#') + // if we should discard the url fragment for this site, return an empty string as + // the processed url fragment + if ($idSite !== false + && self::shouldRemoveURLFragmentFor($idSite)) { - $urlFragment = substr($urlFragment, 0, strlen($urlFragment) - 1); + return ''; + } + else + { + // Remove trailing Hash tag in ?query#hash# + if (substr($urlFragment, -1) == '#') + { + $urlFragment = substr($urlFragment, 0, strlen($urlFragment) - 1); + } + return $urlFragment; } - return $urlFragment; } - + + /** + * Returns true if URL fragments should be removed for a specific site, + * false if otherwise. + * + * This function uses the Tracker cache and not the MySQL database. + * + * @param $idSite int The ID of the site to check for. + * @return bool + */ + public static function shouldRemoveURLFragmentFor( $idSite ) + { + $websiteAttributes = Piwik_Common::getCacheWebsiteAttributes($idSite); + return !$websiteAttributes['keep_url_fragment']; + } /** * Given the Input URL, will exclude all query parameters set for this site @@ -329,7 +361,7 @@ class Piwik_Tracker_Action implements Piwik_Tracker_Action_Interface $originalUrl = self::cleanupUrl($originalUrl); $parsedUrl = @parse_url($originalUrl); - $parsedUrl = self::cleanupHostAndHashTag($parsedUrl); + $parsedUrl = self::cleanupHostAndHashTag($parsedUrl, $idSite); $parametersToExclude = self::getQueryParametersToExclude($idSite); if(empty($parsedUrl['query'])) diff --git a/core/Updates/1.10.2-b2.php b/core/Updates/1.10.2-b2.php new file mode 100644 index 0000000000..c18bfd677d --- /dev/null +++ b/core/Updates/1.10.2-b2.php @@ -0,0 +1,30 @@ +<?php +/** + * Piwik - Open source web analytics + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + * + * @category Piwik + * @package Updates + */ + +/** + * @package Updates + */ +class Piwik_Updates_1_10_2_b2 extends Piwik_Updates +{ + static function getSql($schema = 'Myisam') + { + return array( + // ignore existing column name error (1060) + 'ALTER TABLE '.Piwik_Common::prefixTable('site') + . " ADD COLUMN `keep_url_fragment` TINYINT NOT NULL DEFAULT 0 AFTER `group`" => 1060, + ); + } + + static function update() + { + Piwik_Updater::updateDatabase(__FILE__, self::getSql()); + } +} diff --git a/core/Version.php b/core/Version.php index c8bc2f19b5..46e829821c 100644 --- a/core/Version.php +++ b/core/Version.php @@ -20,5 +20,5 @@ final class Piwik_Version * Current Piwik version * @var string */ - const VERSION = '1.10.2-b1'; + const VERSION = '1.10.2-b2'; } diff --git a/lang/en.php b/lang/en.php index 7bbbb0af6b..8aa5a90283 100644 --- a/lang/en.php +++ b/lang/en.php @@ -1299,6 +1299,10 @@ And thank you for using Piwik!', 'SitesManager_SearchUseDefault' => 'Use %sdefault%s Site Search parameters', 'SitesManager_EnableSiteSpecificUserAgentExclude' => 'Enable website specific user agent exclusion.', 'SitesManager_EnableSiteSpecificUserAgentExclude_Help' => 'If you need to exclude different user agents for different websites, check this box, click save and %1$sadd the user agents above%2$s.', + 'SitesManager_KeepURLFragments' => 'Keep URL Fragments', + 'SitesManager_KeepURLFragmentsHelp' => 'If the checkbox below is unchecked, URL fragments (everything after the %1$s) will be removed when tracking so %2$s will be considered the same as %3$s or %4$s.', + 'SitesManager_KeepURLFragmentsHelp2' => 'You can override this setting for individual websites above.', + 'SitesManager_KeepURLFragmentsLong' => 'Keep URL fragments when tracking', 'TranslationsAdmin_PluginDescription' => 'Help translate Piwik into your language.', 'TranslationsAdmin_MenuTranslations' => 'Translations', 'TranslationsAdmin_MenuLanguages' => 'Languages', diff --git a/plugins/SitesManager/API.php b/plugins/SitesManager/API.php index 0575a265cb..4b15bc8740 100644 --- a/plugins/SitesManager/API.php +++ b/plugins/SitesManager/API.php @@ -50,6 +50,7 @@ class Piwik_SitesManager_API const OPTION_SEARCH_CATEGORY_QUERY_PARAMETERS_GLOBAL = 'SitesManager_SearchCategoryParameters'; const OPTION_EXCLUDED_USER_AGENTS_GLOBAL = 'SitesManager_ExcludedUserAgentsGlobal'; const OPTION_SITE_SPECIFIC_USER_AGENT_EXCLUDE_ENABLE = 'SitesManager_EnableSiteSpecificUserAgentExclude'; + const OPTION_KEEP_URL_FRAGMENTS_GLOBAL = 'SitesManager_KeepURLFragmentsGlobal'; /** * Returns the javascript tag for the given idSite. @@ -448,7 +449,9 @@ class Piwik_SitesManager_API * @param string Currency, eg. 'EUR' * @param string Website group identifier * @param string Date at which the statistics for this website will start. Defaults to today's date in YYYY-MM-DD format - * + * @param int $keepURLFragments If 1, URL fragments will be kept when tracking. If 2, they + * will be removed. If 0, the default global behavior will be used. + * @see getKeepURLFragmentsGlobal. * * @return int the website ID created */ @@ -464,7 +467,8 @@ class Piwik_SitesManager_API $currency = null, $group = null, $startDate = null, - $excludedUserAgents = null ) + $excludedUserAgents = null, + $keepURLFragments = 0 ) { Piwik::checkUserIsSuperUser(); @@ -474,6 +478,9 @@ class Piwik_SitesManager_API $this->checkAtLeastOneUrl($urls); $siteSearch = $this->checkSiteSearch($siteSearch); list($searchKeywordParameters, $searchCategoryParameters ) = $this->checkSiteSearchParameters($searchKeywordParameters, $searchCategoryParameters); + + $keepURLFragments = (int)$keepURLFragments; + self::checkKeepURLFragmentsValue($keepURLFragments); $timezone = trim($timezone); if(empty($timezone)) @@ -501,6 +508,7 @@ class Piwik_SitesManager_API $bind['excluded_ips'] = $this->checkAndReturnExcludedIps($excludedIps); $bind['excluded_parameters'] = $this->checkAndReturnCommaSeparatedStringList($excludedQueryParameters); $bind['excluded_user_agents'] = $this->checkAndReturnCommaSeparatedStringList($excludedUserAgents); + $bind['keep_url_fragment'] = $keepURLFragments; $bind['timezone'] = $timezone; $bind['currency'] = $currency; $bind['ecommerce'] = (int)$ecommerce; @@ -820,6 +828,37 @@ class Piwik_SitesManager_API } /** + * Returns true if the default behavior is to keep URL fragments when tracking, + * false if otherwise. + * + * @return bool + */ + public function getKeepURLFragmentsGlobal() + { + Piwik::checkUserHasSomeViewAccess(); + return (bool)Piwik_GetOption(self::OPTION_KEEP_URL_FRAGMENTS_GLOBAL); + } + + /** + * Sets whether the default behavior should be to keep URL fragments when + * tracking or not. + * + * @param $enabled bool If true, the default behavior will be to keep URL + * fragments when tracking. If false, the default + * behavior will be to remove them. + */ + public function setKeepURLFragmentsGlobal( $enabled ) + { + Piwik::checkUserIsSuperUser(); + + // update option + Piwik_SetOption(self::OPTION_KEEP_URL_FRAGMENTS_GLOBAL, $enabled); + + // make sure tracker cache will reflect change + Piwik_Common::deleteTrackerCache(); + } + + /** * Sets list of URL query parameters to be excluded on all websites. * Will also apply to websites created in the future. * @@ -924,6 +963,10 @@ class Piwik_SitesManager_API * @param string $currency Currency code * @param string $group Group name where this website belongs * @param string $startDate Date at which the statistics for this website will start. Defaults to today's date in YYYY-MM-DD format + * @param int|null $keepURLFragments If 1, URL fragments will be kept when tracking. If 2, they + * will be removed. If 0, the default global behavior will be used. + * @see getKeepURLFragmentsGlobal. If null, the existing value will + * not be modified. * * @throws Exception * @return bool true on success @@ -941,7 +984,8 @@ class Piwik_SitesManager_API $currency = null, $group = null, $startDate = null, - $excludedUserAgents = null) + $excludedUserAgents = null, + $keepURLFragments = null) { Piwik::checkUserHasAdminAccess($idSite); @@ -992,6 +1036,14 @@ class Piwik_SitesManager_API $bind['excluded_ips'] = $this->checkAndReturnExcludedIps($excludedIps); $bind['excluded_parameters'] = $this->checkAndReturnCommaSeparatedStringList($excludedQueryParameters); $bind['excluded_user_agents'] = $this->checkAndReturnCommaSeparatedStringList($excludedUserAgents); + + if (!is_null($keepURLFragments)) + { + $keepURLFragments = (int)$keepURLFragments; + self::checkKeepURLFragmentsValue($keepURLFragments); + + $bind['keep_url_fragment'] = $keepURLFragments; + } $bind['sitesearch'] = $this->checkSiteSearch($siteSearch); list($searchKeywordParameters, $searchCategoryParameters ) = $this->checkSiteSearchParameters($searchKeywordParameters, $searchCategoryParameters); @@ -1339,4 +1391,21 @@ class Piwik_SitesManager_API $bind) ; return $sites; } + + /** + * Utility function that throws if a value is not valid for the 'keep_url_fragment' + * column of the piwik_site table. + * + * @param int $keepURLFragments + * @throws Exception + */ + private static function checkKeepURLFragmentsValue( $keepURLFragments ) + { + if ($keepURLFragments < 0 + || $keepURLFragments > 2) // make sure value is between 0 & 2 + { + throw new Exception("Error in SitesManager.updateSite: keepURLFragments must be between 0 & 2" + + " (actual value: $keepURLFragments)."); + } + } } diff --git a/plugins/SitesManager/Controller.php b/plugins/SitesManager/Controller.php index 7c3a1653f8..0766fc835c 100644 --- a/plugins/SitesManager/Controller.php +++ b/plugins/SitesManager/Controller.php @@ -67,6 +67,8 @@ class Piwik_SitesManager_Controller extends Piwik_Controller_Admin $view->allowSiteSpecificUserAgentExclude = Piwik_SitesManager_API::getInstance()->isSiteSpecificUserAgentExcludeEnabled(); + $view->globalKeepURLFragments = Piwik_SitesManager_API::getInstance()->getKeepURLFragmentsGlobal(); + $view->currentIpAddress = Piwik_IP::getIpFromHeader(); $view->showAddSite = (boolean) Piwik_Common::getRequestVar('showaddsite', false); @@ -93,14 +95,18 @@ class Piwik_SitesManager_Controller extends Piwik_Controller_Admin $searchKeywordParameters = Piwik_Common::getRequestVar('searchKeywordParameters', $default = ""); $searchCategoryParameters = Piwik_Common::getRequestVar('searchCategoryParameters', $default = ""); $enableSiteUserAgentExclude = Piwik_Common::getRequestVar('enableSiteUserAgentExclude', $default = 0); - Piwik_SitesManager_API::getInstance()->setDefaultTimezone($timezone); - Piwik_SitesManager_API::getInstance()->setDefaultCurrency($currency); - Piwik_SitesManager_API::getInstance()->setGlobalExcludedQueryParameters($excludedQueryParameters); - Piwik_SitesManager_API::getInstance()->setGlobalExcludedIps($excludedIps); - Piwik_SitesManager_API::getInstance()->setGlobalExcludedUserAgents($excludedUserAgents); - Piwik_SitesManager_API::getInstance()->setGlobalSearchParameters($searchKeywordParameters, $searchCategoryParameters); - Piwik_SitesManager_API::getInstance()->setSiteSpecificUserAgentExcludeEnabled( - $enableSiteUserAgentExclude == 1); + $keepURLFragments = Piwik_Common::getRequestVar('keepURLFragments', $default = 0); + + $api = Piwik_SitesManager_API::getInstance(); + $api->setDefaultTimezone($timezone); + $api->setDefaultCurrency($currency); + $api->setGlobalExcludedQueryParameters($excludedQueryParameters); + $api->setGlobalExcludedIps($excludedIps); + $api->setGlobalExcludedUserAgents($excludedUserAgents); + $api->setGlobalSearchParameters($searchKeywordParameters, $searchCategoryParameters); + $api->setSiteSpecificUserAgentExcludeEnabled($enableSiteUserAgentExclude == 1); + $api->setKeepURLFragmentsGlobal($keepURLFragments); + $toReturn = $response->getResponse(); } catch(Exception $e ) { $toReturn = $response->getResponseException( $e ); diff --git a/plugins/SitesManager/SitesManager.php b/plugins/SitesManager/SitesManager.php index d86b50025c..939b7116b7 100644 --- a/plugins/SitesManager/SitesManager.php +++ b/plugins/SitesManager/SitesManager.php @@ -15,6 +15,10 @@ */ class Piwik_SitesManager extends Piwik_Plugin { + const KEEP_URL_FRAGMENT_USE_DEFAULT = 0; + const KEEP_URL_FRAGMENT_YES = 1; + const KEEP_URL_FRAGMENT_NO = 2; + public function getInformation() { $info = array( @@ -86,10 +90,31 @@ class Piwik_SitesManager extends Piwik_Plugin $array['excluded_ips'] = $this->getTrackerExcludedIps($website); $array['excluded_parameters'] = self::getTrackerExcludedQueryParameters($website); $array['excluded_user_agents'] = self::getExcludedUserAgents($website); + $array['keep_url_fragment'] = self::shouldKeepURLFragmentsFor($website); $array['sitesearch'] = $website['sitesearch']; $array['sitesearch_keyword_parameters'] = $this->getTrackerSearchKeywordParameters($website); $array['sitesearch_category_parameters'] = $this->getTrackerSearchCategoryParameters($website); } + + /** + * Returns whether we should keep URL fragments for a specific site. + * + * @param array $site DB data for the site. + * @return bool + */ + private static function shouldKeepURLFragmentsFor( $site ) + { + if ($site['keep_url_fragment'] == self::KEEP_URL_FRAGMENT_YES) + { + return true; + } + else if ($site['keep_url_fragment'] == self::KEEP_URL_FRAGMENT_NO) + { + return false; + } + + return Piwik_SitesManager_API::getInstance()->getKeepURLFragmentsGlobal(); + } private function getTrackerSearchKeywordParameters($website) { diff --git a/plugins/SitesManager/templates/SitesManager.js b/plugins/SitesManager/templates/SitesManager.js index 09d825f7f7..c53ec58009 100644 --- a/plugins/SitesManager/templates/SitesManager.js +++ b/plugins/SitesManager/templates/SitesManager.js @@ -5,6 +5,7 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */ +// NOTE: if you cannot find the definition of a variable here, look in SitesManager.tpl function SitesManager ( _timezones, _currencies, _defaultTimezone, _defaultCurrency ) { var timezones = _timezones; @@ -41,6 +42,7 @@ function SitesManager ( _timezones, _currencies, _defaultTimezone, _defaultCurre excludedQueryParameters = piwikHelper.getApiFormatTextarea(excludedQueryParameters); var excludedUserAgents = $(row).find('textarea#excludedUserAgents').val(); excludedUserAgents = piwikHelper.getApiFormatTextarea(excludedUserAgents); + var keepURLFragments = $('#keepURLFragmentSelect', row).val(); var ecommerce = $(row).find('#ecommerce option:selected').val(); var sitesearch = $(row).find('#sitesearch option:selected').val(); var searchKeywordParameters = $('input#searchKeywordParameters').val(); @@ -60,6 +62,7 @@ function SitesManager ( _timezones, _currencies, _defaultTimezone, _defaultCurre excludedIps: excludedIps, excludedQueryParameters: excludedQueryParameters, excludedUserAgents: excludedUserAgents, + keepURLFragments: keepURLFragments, siteSearch: sitesearch, searchKeywordParameters: searchKeywordParameters, searchCategoryParameters: searchCategoryParameters, @@ -82,6 +85,7 @@ function SitesManager ( _timezones, _currencies, _defaultTimezone, _defaultCurre excludedQueryParameters = piwikHelper.getApiFormatTextarea(excludedQueryParameters); var excludedUserAgents = $(row).find('textarea#excludedUserAgents').val(); excludedUserAgents = piwikHelper.getApiFormatTextarea(excludedUserAgents); + var keepURLFragments = $('#keepURLFragmentSelect', row).val(); var timezone = $(row).find('#timezones option:selected').val(); var currency = $(row).find('#currencies option:selected').val(); var ecommerce = $(row).find('#ecommerce option:selected').val(); @@ -104,6 +108,7 @@ function SitesManager ( _timezones, _currencies, _defaultTimezone, _defaultCurre excludedIps: excludedIps, excludedQueryParameters: excludedQueryParameters, excludedUserAgents: excludedUserAgents, + keepURLFragments: keepURLFragments, siteSearch: sitesearch, searchKeywordParameters: searchKeywordParameters, searchCategoryParameters: searchCategoryParameters, @@ -124,6 +129,7 @@ function SitesManager ( _timezones, _currencies, _defaultTimezone, _defaultCurre excludedQueryParameters = piwikHelper.getApiFormatTextarea(excludedQueryParameters); var globalExcludedUserAgents = $('textarea#globalExcludedUserAgents').val(); globalExcludedUserAgents = piwikHelper.getApiFormatTextarea(globalExcludedUserAgents); + var globalKeepURLFragments = $('#globalKeepURLFragments').is(':checked') ? 1 : 0; var searchKeywordParameters = $('input#globalSearchKeywordParameters').val(); var searchCategoryParameters = $('input#globalSearchCategoryParameters').val(); var enableSiteUserAgentExclude = $('input#enableSiteUserAgentExclude').is(':checked') ? 1 : 0; @@ -140,6 +146,7 @@ function SitesManager ( _timezones, _currencies, _defaultTimezone, _defaultCurre excludedIps: excludedIps, excludedQueryParameters: excludedQueryParameters, excludedUserAgents: globalExcludedUserAgents, + keepURLFragments: globalKeepURLFragments, enableSiteUserAgentExclude: enableSiteUserAgentExclude, searchKeywordParameters: searchKeywordParameters, searchCategoryParameters: searchCategoryParameters @@ -165,6 +172,7 @@ function SitesManager ( _timezones, _currencies, _defaultTimezone, _defaultCurre <td><textarea cols="20" rows="4" id="excludedIps"></textarea><br />'+excludedIpHelp+'</td>\ <td><textarea cols="20" rows="4" id="excludedQueryParameters"></textarea><br />'+excludedQueryParametersHelp+'</td>\ <td><textarea cols="20" rows="4" id="excludedUserAgents"></textarea><br />'+excludedUserAgentsHelp+'</td>\ + <td>'+keepURLFragmentSelectHTML+'</td>\ <td>'+getSitesearchSelector(false)+'</td>\ <td>'+getTimezoneSelector(defaultTimezone)+'<br />' + timezoneHelp + '</td>\ <td>'+getCurrencySelector(defaultCurrency)+'<br />' + currencyHelp + '</td>\ @@ -264,6 +272,15 @@ function SitesManager ( _timezones, _currencies, _defaultTimezone, _defaultCurre contentBefore.replace(/<br *\/? *>/gi,"\n")+'</textarea><br />'+excludedUserAgentsHelp; $(n).html(contentAfter); } + else if (idName == 'keepURLFragments') + { + $(n).html(keepURLFragmentSelectHTML) + // find the option to select by the option text and select it + .find('option').each(function() { + this.selected = this.text == contentBefore + || (this.value == 0 && contentBefore == '-'); + }); + } else if(idName == 'timezone') { var contentAfter = getTimezoneSelector(contentBefore); diff --git a/plugins/SitesManager/templates/SitesManager.tpl b/plugins/SitesManager/templates/SitesManager.tpl index 2c108e0210..89c646f94f 100644 --- a/plugins/SitesManager/templates/SitesManager.tpl +++ b/plugins/SitesManager/templates/SitesManager.tpl @@ -42,6 +42,14 @@ var aliasUrlsHelp = '{'SitesManager_AliasUrlHelp'|translate|inlineHelp|escape:ja {'SitesManager_GlobalListExcludedUserAgents_Desc'|translate} {'SitesManager_GlobalExcludedUserAgentHelp2'|translate} {/capture} {assign var=excludedUserAgentsHelp value=$excludedUserAgentsHelp|inlineHelp} + +{capture assign=keepURLFragmentSelectHTML} + <select id="keepURLFragmentSelect"> + <option value="0">{'General_Default'|translate}</option> + <option value="1">{'General_Yes'|translate}</option> + <option value="2">{'General_No'|translate}</option> + </select> +{/capture} var excludedQueryParametersHelp = '{$excludedQueryParametersHelp|escape:javascript}'; var excludedUserAgentsHelp = '{$excludedUserAgentsHelp|escape:javascript}'; var timezoneHelp = '{$timezoneHelpPlain|inlineHelp|escape:javascript}'; @@ -58,6 +66,7 @@ var sitesearchDisabled = '{'SitesManager_DisableSiteSearch'|translate|escape:jav var searchKeywordHelp = '{$searchKeywordHelp|escape:javascript}'; var searchCategoryHelp = '{$searchCategoryHelp|escape:javascript}'; var sitesearchDesc = '{'SitesManager_TrackingSiteSearch'|translate|escape:javascript}'; +var keepURLFragmentSelectHTML = '{$keepURLFragmentSelectHTML|escape:javascript}'; var sitesManager = new SitesManager ( {$timezones}, {$currencies}, '{$defaultTimezone}', '{$defaultCurrency}'); {assign var=searchKeywordLabel value='SitesManager_SearchKeywordLabel'|translate} @@ -147,6 +156,7 @@ vertical-align:middle; <th>{'SitesManager_ExcludedIps'|translate}</th> <th>{'SitesManager_ExcludedParameters'|translate|replace:" ":"<br />"}</th> <th id='exclude-user-agent-header' {if !$allowSiteSpecificUserAgentExclude}style="display:none"{/if}>{'SitesManager_ExcludedUserAgents'|translate}</th> + <th>{'SitesManager_KeepURLFragments'|translate}</th> <th>{'Actions_SubmenuSitesearch'|translate}</th> <th>{'SitesManager_Timezone'|translate}</th> <th>{'SitesManager_Currency'|translate}</th> @@ -165,6 +175,7 @@ vertical-align:middle; <td id="excludedIps" class="editableSite">{foreach from=$site.excluded_ips item=ip}{$ip}<br />{/foreach}</td> <td id="excludedQueryParameters" class="editableSite">{foreach from=$site.excluded_parameters item=parameter}{$parameter}<br />{/foreach}</td> <td id="excludedUserAgents" class="editableSite" {if !$allowSiteSpecificUserAgentExclude}style="display:none"{/if}>{foreach from=$site.excluded_user_agents item=ua}{$ua}<br />{/foreach}</td> + <td id="keepURLFragments" class="editableSite">{if $site.keep_url_fragment eq 0}-{elseif $site.keep_url_fragment eq 1}{'General_Yes'|translate}{else}{'General_No'|translate}{/if}</td> <td id="sitesearch" class="editableSite">{if $site.sitesearch}<span class='sitesearchActive'>{'General_Yes'|translate}</span>{else}<span class='sitesearchInactive'>-</span>{/if}<span class='sskp' sitesearch_keyword_parameters="{$site.sitesearch_keyword_parameters|escape:'html'}" sitesearch_category_parameters="{$site.sitesearch_category_parameters|escape:'html'}" id="sitesearch_parameters"></span></td> <td id="timezone" class="editableSite">{$site.timezone}</td> <td id="currency" class="editableSite">{$site.currency}</td> @@ -234,7 +245,17 @@ vertical-align:middle; <span id='enableSiteUserAgentExclude-loading' class='loadingPiwik' style='display:none'><img src='./themes/default/images/loading-blue.gif' /></span> </td><td>{'SitesManager_EnableSiteSpecificUserAgentExclude_Help'|translate:'<a href="#editSites">':'</a>'|inlineHelp} </td></tr> + + {* global keep URL fragments *} + <tr><td colspan="2"> + <strong>{'SitesManager_KeepURLFragments'|translate}</strong> + <p>{'SitesManager_KeepURLFragmentsHelp'|translate:"<em>#</em>":"<em>http://www.example.org/index.html#first_section</em>":"<em>http://www.example.org/index.html</em>":"<em>http://www.example.org/index.html#second_section</em>"}</p> + <p>{'SitesManager_KeepURLFragmentsHelp2'|translate}</p> + <input type="checkbox" id="globalKeepURLFragments" name="globalKeepURLFragments" {if $globalKeepURLFragments}checked="checked"{/if}/> + <label for="globalKeepURLFragments">{'SitesManager_KeepURLFragmentsLong'|translate}</label> + </td></tr> + {* global site search *} <tr><td colspan="2"> <a name='globalSiteSearch'></a><b>{'SitesManager_TrackingSiteSearch'|translate}</b> <p>{$sitesearchIntro}</p> diff --git a/tests/PHPUnit/Core/Tracker/ActionTest.php b/tests/PHPUnit/Core/Tracker/ActionTest.php index f4f0bbb76b..3e661c8611 100644 --- a/tests/PHPUnit/Core/Tracker/ActionTest.php +++ b/tests/PHPUnit/Core/Tracker/ActionTest.php @@ -107,7 +107,8 @@ class Tracker_ActionTest extends DatabaseTestCase $this->setUpRootAccess(); $idSite = Piwik_SitesManager_API::getInstance()->addSite("site1",array('http://example.org'),$ecommerce=0, $siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null, - $excludedIps = '', $excludedQueryParameters=''); + $excludedIps = '', $excludedQueryParameters='', $timezone = null, $currency = null, + $group = null, $startDate = null, $excludedUserAgents = null, $keepURLFragments = 1); $this->assertEquals($filteredUrl[0], Piwik_Tracker_Action::excludeQueryParametersFromUrl($url, $idSite)); } @@ -150,7 +151,8 @@ class Tracker_ActionTest extends DatabaseTestCase $this->setUpRootAccess(); $idSite = Piwik_SitesManager_API::getInstance()->addSite("site1",array('http://example.org'),$ecommerce=0, $siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null, - $excludedIps = '', $excludedQueryParameters); + $excludedIps = '', $excludedQueryParameters, $timezone = null, $currency = null, + $group = null, $startDate = null, $excludedUserAgents = null, $keepURLFragments = 1); $this->assertEquals($filteredUrl[1], Piwik_Tracker_Action::excludeQueryParametersFromUrl($url, $idSite)); } @@ -169,7 +171,8 @@ class Tracker_ActionTest extends DatabaseTestCase $this->setUpRootAccess(); $idSite = Piwik_SitesManager_API::getInstance()->addSite("site1",array('http://example.org'),$ecommerce=0, $siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null, - $excludedIps = '', $excludedQueryParameters); + $excludedIps = '', $excludedQueryParameters, $timezone = null, $currency = null, + $group = null, $startDate = null, $excludedUserAgents = null, $keepURLFragments = 1); Piwik_SitesManager_API::getInstance()->setGlobalExcludedQueryParameters($excludedGlobalParameters); $this->assertEquals($filteredUrl[1], Piwik_Tracker_Action::excludeQueryParametersFromUrl($url, $idSite)); } diff --git a/tests/PHPUnit/Integration/OneVisitorTwoVisitsTest.php b/tests/PHPUnit/Integration/OneVisitorTwoVisitsTest.php index d8dd2f6c6b..0ebc799ce7 100755 --- a/tests/PHPUnit/Integration/OneVisitorTwoVisitsTest.php +++ b/tests/PHPUnit/Integration/OneVisitorTwoVisitsTest.php @@ -248,7 +248,7 @@ class Test_Piwik_Integration_OneVisitorTwoVisits extends IntegrationTestCase $t->setBrowserLanguage('fr'); // Final page view (after 27 min) $t->setForceVisitDateTime(Piwik_Date::factory($dateTime)->addHour(0.45)->getDatetime()); - $t->setUrl('http://example.org/index.htm'); + $t->setUrl('http://example.org/index.htm#ignoredFragment'); self::checkResponse($t->doTrackPageView('Looking at homepage (again)...')); // - diff --git a/tests/PHPUnit/Integration/TwoVisitors_TwoWebsites_DifferentDaysTest.php b/tests/PHPUnit/Integration/TwoVisitors_TwoWebsites_DifferentDaysTest.php index 539912ba7c..d299d64818 100755 --- a/tests/PHPUnit/Integration/TwoVisitors_TwoWebsites_DifferentDaysTest.php +++ b/tests/PHPUnit/Integration/TwoVisitors_TwoWebsites_DifferentDaysTest.php @@ -134,6 +134,17 @@ class Test_Piwik_Integration_TwoVisitors_TwoWebsites_DifferentDays extends Integ Piwik_Goals_API::getInstance()->addGoal(self::$idSite1, 'all', 'url', 'http', 'contains', false, 5); Piwik_Goals_API::getInstance()->addGoal(self::$idSite2, 'all', 'url', 'http', 'contains'); } + + Piwik_SitesManager_API::getInstance()->updateSite( + self::$idSite1, "Site 1", $urls = null, $ecommerce = null, $siteSearch = null, + $searchKeywordParameters = null, $searchCategoryParameters = null, $excludedIps = null, + $excludedQueryParameters = null, $timezone = null, $currency = null, $group = null, + $startDate = null, $excludedUserAgents = null, $keepURLFragments = 2); // No for idSite 1 + Piwik_SitesManager_API::getInstance()->updateSite( + self::$idSite2, "Site 2", $urls = null, $ecommerce = null, $siteSearch = null, + $searchKeywordParameters = null, $searchCategoryParameters = null, $excludedIps = null, + $excludedQueryParameters = null, $timezone = null, $currency = null, $group = null, + $startDate = null, $excludedUserAgents = null, $keepURLFragments = 1); // Yes for idSite 2 } protected static function trackVisits() @@ -147,7 +158,7 @@ class Test_Piwik_Integration_TwoVisitors_TwoWebsites_DifferentDays extends Integ $datetimeSpanOverTwoDays = '2010-01-03 23:55:00'; $visitorA = self::getTracker($idSite, $datetimeSpanOverTwoDays, $defaultInit = true); $visitorA->setUrlReferrer('http://referer.com/page.htm?param=valuewith some spaces'); - $visitorA->setUrl('http://example.org/index.htm'); + $visitorA->setUrl('http://example.org/index.htm#ignoredFragment'); $visitorA->DEBUG_APPEND_URL = '&_idts=' . Piwik_Date::factory($datetimeSpanOverTwoDays)->getTimestamp(); self::checkResponse($visitorA->doTrackPageView('first page view')); @@ -201,7 +212,7 @@ class Test_Piwik_Integration_TwoVisitors_TwoWebsites_DifferentDays extends Integ $visitorAsite2 = self::getTracker($idSite2, Piwik_Date::factory($dateTime)->addHour(24)->getDatetime(), $defaultInit = true); $visitorAsite2->setUserAgent('Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0;)'); $visitorAsite2->setUrlReferrer('http://only-homepage-referer.com/'); - $visitorAsite2->setUrl('http://example2.com/home'); + $visitorAsite2->setUrl('http://example2.com/home#notIgnoredFragment'); $visitorAsite2->DEBUG_APPEND_URL = '&_idts=' . Piwik_Date::factory($dateTime)->addHour(24)->getTimestamp(); self::checkResponse($visitorAsite2->doTrackPageView('Website 2 page view')); // test with invalid URL diff --git a/tests/PHPUnit/Integration/expected/test_TwoVisitors_twoWebsites_differentDays__Actions.getPageUrls_day.xml b/tests/PHPUnit/Integration/expected/test_TwoVisitors_twoWebsites_differentDays__Actions.getPageUrls_day.xml index ecbc005807..ffd726354d 100644 --- a/tests/PHPUnit/Integration/expected/test_TwoVisitors_twoWebsites_differentDays__Actions.getPageUrls_day.xml +++ b/tests/PHPUnit/Integration/expected/test_TwoVisitors_twoWebsites_differentDays__Actions.getPageUrls_day.xml @@ -96,7 +96,7 @@ <result date="2010-01-03" /> <result date="2010-01-04"> <row> - <label>/home</label> + <label>/home#notIgnoredFragment</label> <nb_visits>1</nb_visits> <nb_uniq_visitors>1</nb_uniq_visitors> <nb_hits>1</nb_hits> @@ -109,7 +109,7 @@ <avg_time_on_page>0</avg_time_on_page> <bounce_rate>0%</bounce_rate> <exit_rate>0%</exit_rate> - <url>http://example2.com/home</url> + <url>http://example2.com/home#notIgnoredFragment</url> </row> <row> <label>Page URL not defined</label> diff --git a/tests/PHPUnit/Integration/expected/test_TwoVisitors_twoWebsites_differentDays__Actions.getPageUrls_month.xml b/tests/PHPUnit/Integration/expected/test_TwoVisitors_twoWebsites_differentDays__Actions.getPageUrls_month.xml index 733039fac3..6f0e0a1be6 100644 --- a/tests/PHPUnit/Integration/expected/test_TwoVisitors_twoWebsites_differentDays__Actions.getPageUrls_month.xml +++ b/tests/PHPUnit/Integration/expected/test_TwoVisitors_twoWebsites_differentDays__Actions.getPageUrls_month.xml @@ -71,7 +71,7 @@ <result idSite="2"> <result date="2010-01"> <row> - <label>/home</label> + <label>/home#notIgnoredFragment</label> <nb_visits>1</nb_visits> <nb_hits>1</nb_hits> <sum_time_spent>0</sum_time_spent> @@ -84,7 +84,7 @@ <avg_time_on_page>0</avg_time_on_page> <bounce_rate>0%</bounce_rate> <exit_rate>0%</exit_rate> - <url>http://example2.com/home</url> + <url>http://example2.com/home#notIgnoredFragment</url> </row> <row> <label>Page URL not defined</label> diff --git a/tests/PHPUnit/Integration/expected/test_TwoVisitors_twoWebsites_differentDays__Actions.getPageUrls_week.xml b/tests/PHPUnit/Integration/expected/test_TwoVisitors_twoWebsites_differentDays__Actions.getPageUrls_week.xml index ba482d9d1b..9d5e4dabe1 100644 --- a/tests/PHPUnit/Integration/expected/test_TwoVisitors_twoWebsites_differentDays__Actions.getPageUrls_week.xml +++ b/tests/PHPUnit/Integration/expected/test_TwoVisitors_twoWebsites_differentDays__Actions.getPageUrls_week.xml @@ -84,7 +84,7 @@ <result date="From 2009-12-28 to 2010-01-03" /> <result date="From 2010-01-04 to 2010-01-10"> <row> - <label>/home</label> + <label>/home#notIgnoredFragment</label> <nb_visits>1</nb_visits> <nb_hits>1</nb_hits> <sum_time_spent>0</sum_time_spent> @@ -97,7 +97,7 @@ <avg_time_on_page>0</avg_time_on_page> <bounce_rate>0%</bounce_rate> <exit_rate>0%</exit_rate> - <url>http://example2.com/home</url> + <url>http://example2.com/home#notIgnoredFragment</url> </row> <row> <label>Page URL not defined</label> diff --git a/tests/PHPUnit/Integration/expected/test_TwoVisitors_twoWebsites_differentDays__Actions.getPageUrls_year.xml b/tests/PHPUnit/Integration/expected/test_TwoVisitors_twoWebsites_differentDays__Actions.getPageUrls_year.xml index 1806e680c7..5df8e59be9 100644 --- a/tests/PHPUnit/Integration/expected/test_TwoVisitors_twoWebsites_differentDays__Actions.getPageUrls_year.xml +++ b/tests/PHPUnit/Integration/expected/test_TwoVisitors_twoWebsites_differentDays__Actions.getPageUrls_year.xml @@ -71,7 +71,7 @@ <result idSite="2"> <result date="2010"> <row> - <label>/home</label> + <label>/home#notIgnoredFragment</label> <nb_visits>1</nb_visits> <nb_hits>1</nb_hits> <sum_time_spent>0</sum_time_spent> @@ -84,7 +84,7 @@ <avg_time_on_page>0</avg_time_on_page> <bounce_rate>0%</bounce_rate> <exit_rate>0%</exit_rate> - <url>http://example2.com/home</url> + <url>http://example2.com/home#notIgnoredFragment</url> </row> <row> <label>Page URL not defined</label> |