Changeset 7189
- Timestamp:
- 01/25/08 18:29:15 (5 years ago)
- Files:
-
- plugins/sfGoogleAnalyticsPlugin/trunk/README (modified) (15 diffs)
- plugins/sfGoogleAnalyticsPlugin/trunk/config/app.yml (modified) (1 diff)
- plugins/sfGoogleAnalyticsPlugin/trunk/config/config.php (modified) (1 diff)
- plugins/sfGoogleAnalyticsPlugin/trunk/lib/action/sfGoogleAnalyticsActionMixin.class.php (moved) (moved from plugins/sfGoogleAnalyticsPlugin/trunk/lib/action/sfUrchinActionMixin.class.php) (4 diffs)
- plugins/sfGoogleAnalyticsPlugin/trunk/lib/exception/sfGoogleAnalyticsException.class.php (moved) (moved from plugins/sfGoogleAnalyticsPlugin/trunk/lib/exception/sfUrchinException.class.php) (1 diff)
- plugins/sfGoogleAnalyticsPlugin/trunk/lib/filter/sfGoogleAnalyticsFilter.class.php (moved) (moved from plugins/sfGoogleAnalyticsPlugin/trunk/lib/filter/sfUrchinFilter.php) (7 diffs)
- plugins/sfGoogleAnalyticsPlugin/trunk/lib/helper/GoogleAnalyticsHelper.php (moved) (moved from plugins/sfGoogleAnalyticsPlugin/trunk/lib/helper/UrchinHelper.php) (3 diffs)
- plugins/sfGoogleAnalyticsPlugin/trunk/lib/util/sfGoogleAnalyticsToolkit.class.php (moved) (moved from plugins/sfGoogleAnalyticsPlugin/trunk/lib/util/sfUrchinToolkit.class.php) (5 diffs)
- plugins/sfGoogleAnalyticsPlugin/trunk/package.xml (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/sfGoogleAnalyticsPlugin/trunk/README
r5612 r7189 1 = sf UrchinPlugin plugin =1 = sfGoogleAnalyticsPlugin plugin = 2 2 3 3 Easily adds tracking code for [http://www.google.com/analytics Google Analytics] to your presentation layer. … … 5 5 == Features == 6 6 7 * `sf UrchinActionMixin`: Adds convenience methods to your actions.8 * `sf UrchinFilter`: Adds necessary tracking code to the bottom of every HTML page.9 * ` UrchinHelper`: Helper functions for adding `urchinTracker` calls to links.7 * `sfGoogleAnalyticsActionMixin`: Adds convenience methods to your actions. 8 * `sfGoogleAnalyticsFilter`: Adds necessary tracking code to the bottom of every HTML page. 9 * `GoogleAnalyticsHelper`: Helper functions for adding `urchinTracker` calls to links. 10 10 11 11 == Installation == … … 14 14 15 15 {{{ 16 ./symfony plugin-install http://plugins.symfony-project.com/sf UrchinPlugin16 ./symfony plugin-install http://plugins.symfony-project.com/sfGoogleAnalyticsPlugin 17 17 }}} 18 18 … … 21 21 {{{ 22 22 prod: 23 urchin:23 google_analytics: 24 24 enabled: on 25 25 uacct: xx-xxxxxxx-x # <-- put your site's account number here 26 26 27 27 all: 28 urchin:28 google_analytics: 29 29 enabled: off 30 30 }}} 31 31 32 * Add `sf UrchinFilter` to `filters.yml` just after `web_debug`:32 * Add `sfGoogleAnalyticsFilter` to `filters.yml` just after `web_debug`: 33 33 34 34 {{{ 35 35 rendering: ~ 36 36 web_debug: ~ 37 urchin:38 class: sf UrchinFilter37 google_analytics: 38 class: sfGoogleAnalyticsFilter 39 39 # etc... 40 40 }}} … … 48 48 {{{ 49 49 // from inside an action 50 null $this->set UrchinParam(string $utParam)50 null $this->setGoogleAnalyticsParam(string $utParam) 51 51 }}} 52 52 … … 57 57 {{{ 58 58 // from inside an action 59 $this->set UrchinParam('/error/404?page='.$this->getModuleName().'/'.$this->getActionName());59 $this->setGoogleAnalyticsParam('/error/404?page='.$this->getModuleName().'/'.$this->getActionName()); 60 60 }}} 61 61 … … 64 64 {{{ 65 65 // from inside an action 66 null $this->add UrchinVar(string $name, string $value)66 null $this->addGoogleAnalyticsVar(string $name, string $value) 67 67 }}} 68 68 … … 71 71 {{{ 72 72 // from inside an action 73 $this->add UrchinVar('udn', 'domain.com');73 $this->addGoogleAnalyticsVar('udn', 'domain.com'); 74 74 }}} 75 75 … … 89 89 90 90 {{{ 91 string urchin_link_to(string $name, string $internalUri[, string $urchinUri[, array $options]])91 string google_analytics_link_to(string $name, string $internalUri[, string $urchinUri[, array $options]]) 92 92 }}} 93 93 … … 97 97 98 98 {{{ 99 <?php use_helper(' Urchin') ?>99 <?php use_helper('GoogleAnalytics') ?> 100 100 101 101 <p> 102 102 For more information, please visit the 103 <?php echo urchin_link_to('symfony project site',104 'http://www.symfony-project.com',105 '/outbound/symfony') ?>.103 <?php echo google_analytics_link_to('symfony project site', 104 'http://www.symfony-project.com', 105 '/outbound/symfony') ?>. 106 106 </p> 107 107 }}} … … 110 110 111 111 {{{ 112 <?php use_helper(' Urchin') ?>112 <?php use_helper('GoogleAnalytics') ?> 113 113 114 114 <p> 115 You can also download <?php echo urchin_link_to('the PDF version',116 '/doc/the-book.pdf') ?>.115 You can also download <?php echo google_analytics_link_to('the PDF version', 116 '/doc/the-book.pdf') ?>. 117 117 </p> 118 118 }}} … … 121 121 122 122 {{{ 123 string urchin_link_to_function(string $name, string $function, string $urchinUri[, array $options])123 string google_analytics_link_to_function(string $name, string $function, string $urchinUri[, array $options]) 124 124 }}} 125 125 … … 127 127 128 128 {{{ 129 <?php use_helper(' Urchin') ?>129 <?php use_helper('GoogleAnalytics') ?> 130 130 131 <p><?php echo urchin_link_to_function('close window',132 'window.close()',133 '/popups/mom/close',134 'id=closer') ?></p>131 <p><?php echo google_analytics_link_to_function('close window', 132 'window.close()', 133 '/popups/mom/close', 134 'id=closer') ?></p> 135 135 }}} 136 136 … … 141 141 {{{ 142 142 prod: 143 urchin:143 google_analytics: 144 144 enabled: on 145 145 146 146 all: 147 urchin:147 google_analytics: 148 148 uacct: xx-xxxxxxx-x 149 149 insertion: top … … 152 152 These settings will place the tracking code just inside the response's opening `<body>` tag (in the `prod` environment). The plugin defaults to placing the tracking code just before the response's closing `</body>` tag. 153 153 154 == Roadmap ==154 == Version 1.1 Roadmap == 155 155 156 Support for: 157 158 * `__utmLinker()` 159 * `__utmLinkPost()` 156 Refactor plugin to accommodate both version of Google Analytics tracking code: legacy Urchin Javascript and the new Google Javascript. 160 157 161 158 == Changelog == 159 160 === Version 1.0-RC1 === 161 162 * Renamed plugin from sfUrchinPlugin to sfGoogleAnalyticsPlugin. 162 163 163 164 === Version 0.3.1-beta === plugins/sfGoogleAnalyticsPlugin/trunk/config/app.yml
r5608 r7189 1 1 # all: 2 # urchin:2 # google_analytics: 3 3 # enabled: off 4 4 # uacct: ~ # Profile number plugins/sfGoogleAnalyticsPlugin/trunk/config/config.php
r5350 r7189 1 1 <?php 2 2 3 sfMixer::register('sfComponent', array('sf UrchinActionMixin', 'setUrchinParam'));4 sfMixer::register('sfComponent', array('sf UrchinActionMixin', 'addUrchinVar'));3 sfMixer::register('sfComponent', array('sfGoogleAnalyticsActionMixin', 'setGoogleAnalyticsParam')); 4 sfMixer::register('sfComponent', array('sfGoogleAnalyticsActionMixin', 'addGoogleAnalyticsVar')); plugins/sfGoogleAnalyticsPlugin/trunk/lib/action/sfGoogleAnalyticsActionMixin.class.php
r5350 r7189 2 2 3 3 /** 4 * Action mixin methods for the sf UrchinPlugin.4 * Action mixin methods for the sfGoogleAnalyticsPlugin. 5 5 * 6 * @package sf UrchinPlugin6 * @package sfGoogleAnalyticsPlugin 7 7 * @subpackage action 8 8 * @author Kris Wallsmith <kris [dot] wallsmith [at] gmail [dot] com> 9 9 * @version SVN: $Id$ 10 10 */ 11 class sf UrchinActionMixin11 class sfGoogleAnalyticsActionMixin 12 12 { 13 13 /** … … 19 19 * @param string $utParam 20 20 */ 21 public static function set UrchinParam($action, $utParam)21 public static function setGoogleAnalyticsParam($action, $utParam) 22 22 { 23 23 $moduleName = $action->getModuleName(); 24 24 $actionName = $action->getActionName(); 25 25 26 $actionConfig = sfConfig::get('mod_'.$moduleName.'_'.$actionName.'_ urchin', array());26 $actionConfig = sfConfig::get('mod_'.$moduleName.'_'.$actionName.'_google_analytics', array()); 27 27 $actionConfig['ut_param'] = $utParam; 28 28 29 sfConfig::set('mod_'.$moduleName.'_'.$actionName.'_ urchin', $actionConfig);29 sfConfig::set('mod_'.$moduleName.'_'.$actionName.'_google_analytics', $actionConfig); 30 30 } 31 31 … … 39 39 * @param string $value 40 40 */ 41 public static function add UrchinVar($action, $name, $value)41 public static function addGoogleAnalyticsVar($action, $name, $value) 42 42 { 43 43 $moduleName = $action->getModuleName(); 44 44 $actionName = $action->getActionName(); 45 45 46 $actionConfig = sfConfig::get('mod_'.$moduleName.'_'.$actionName.'_ urchin', array());46 $actionConfig = sfConfig::get('mod_'.$moduleName.'_'.$actionName.'_google_analytics', array()); 47 47 if (!isset($actionConfig['vars'])) 48 48 { … … 51 51 $actionConfig['vars'][$name] = $value; 52 52 53 sfConfig::set('mod_'.$moduleName.'_'.$actionName.'_ urchin', $actionConfig);53 sfConfig::set('mod_'.$moduleName.'_'.$actionName.'_google_analytics', $actionConfig); 54 54 } 55 55 plugins/sfGoogleAnalyticsPlugin/trunk/lib/exception/sfGoogleAnalyticsException.class.php
r5280 r7189 2 2 3 3 /** 4 * Exception class for sf UrchinPlugin.4 * Exception class for sfGoogleAnalyticsPlugin. 5 5 * 6 * @package sf UrchinPlugin6 * @package sfGoogleAnalyticsPlugin 7 7 * @subpackage exception 8 8 * @author Kris Wallsmith <kris [dot] wallsmith [at] gmail [dot] com> 9 9 * @version SVN: $Id$ 10 10 */ 11 class sf UrchinException extends sfException11 class sfGoogleAnalyticsException extends sfException 12 12 { 13 14 13 } plugins/sfGoogleAnalyticsPlugin/trunk/lib/filter/sfGoogleAnalyticsFilter.class.php
r5612 r7189 11 11 * web_debug: ~ 12 12 * 13 * # sf UrchinPlugin filter14 * urchin:15 * class: sf UrchinFilter13 * # sfGoogleAnalyticsPlugin filter 14 * google_analytics: 15 * class: sfGoogleAnalyticsFilter 16 16 * 17 17 * # etc ... 18 18 * </code> 19 19 * 20 * @package sf UrchinPlugin20 * @package sfGoogleAnalyticsPlugin 21 21 * @subpackage filter 22 22 * @author Kris Wallsmith <kris [dot] wallsmith [at] gmail [dot] com> 23 23 * @version SVN: $Id$ 24 24 */ 25 class sf UrchinFilter extends sfFilter25 class sfGoogleAnalyticsFilter extends sfFilter 26 26 { 27 27 /** … … 38 38 if ($this->isTrackable()) 39 39 { 40 $insertion = sfConfig::get('app_ urchin_insertion', 'bottom');40 $insertion = sfConfig::get('app_google_analytics_insertion', 'bottom'); 41 41 $insertMethod = 'insertTrackingCode'.$insertion; 42 42 … … 45 45 if (sfConfig::get('sf_logging_enabled')) 46 46 { 47 $this->getContext()->getLogger()->info('{sf UrchinFilter} Inserting tracking code in "'.$insertion.'" position.');47 $this->getContext()->getLogger()->info('{sfGoogleAnalyticsFilter} Inserting tracking code in "'.$insertion.'" position.'); 48 48 } 49 49 … … 53 53 else 54 54 { 55 throw new sf UrchinException('Unrecognized insertion.');55 throw new sfGoogleAnalyticsException('Unrecognized insertion.'); 56 56 } 57 57 } 58 58 elseif (sfConfig::get('sf_logging_enabled')) 59 59 { 60 $this->getContext()->getLogger()->info('{sf UrchinFilter} Tracking code not inserted.');60 $this->getContext()->getLogger()->info('{sfGoogleAnalyticsFilter} Tracking code not inserted.'); 61 61 } 62 62 } … … 77 77 78 78 // don't add analytics: 79 // * if urchinis not enabled79 // * if google analytics is not enabled 80 80 // * for XHR requests 81 81 // * if not HTML … … 83 83 // * if not rendering to the client 84 84 // * if HTTP headers only 85 if (!sfConfig::get('app_ urchin_enabled') ||85 if (!sfConfig::get('app_google_analytics_enabled') || 86 86 $request->isXmlHttpRequest() || 87 87 strpos($response->getContentType(), 'html') === false || … … 151 151 protected function generateTrackingCode() 152 152 { 153 return sf UrchinToolkit::getHtml();153 return sfGoogleAnalyticsToolkit::getHtml(); 154 154 } 155 155 } plugins/sfGoogleAnalyticsPlugin/trunk/lib/helper/GoogleAnalyticsHelper.php
r5280 r7189 6 6 * links when analytics is turned off in the configuration. 7 7 * 8 * @package sf UrchinPlugin8 * @package sfGoogleAnalyticsPlugin 9 9 * @subpackage helper 10 10 * @author Kris Wallsmith <kris [dot] wallsmith [at] gmail [dot] com> … … 27 27 * @return string 28 28 */ 29 function urchin_link_to($name, $internalUri, $urchinUri = null, $options = array())29 function google_analytics_link_to($name, $internalUri, $urchinUri = null, $options = array()) 30 30 { 31 if (sfConfig::get('app_urchin_enabled'))31 if (sfConfig::get('app_google_analytics_enabled')) 32 32 { 33 if (!$urchinUri)33 if (!$urchinUri) 34 34 { 35 35 $urchinUri = url_for($internalUri); 36 36 } 37 37 38 $newOnclick = 'urchinTracker(\'' . $urchinUri .'\');';38 $newOnclick = 'urchinTracker(\''.$urchinUri.'\');'; 39 39 40 40 $options = _parse_attributes($options); 41 $options['onclick'] = isset($options['onclick']) ? ($newOnclick .$options['onclick']) : $newOnclick;41 $options['onclick'] = isset($options['onclick']) ? ($newOnclick.$options['onclick']) : $newOnclick; 42 42 } 43 43 … … 55 55 * @return string 56 56 */ 57 function urchin_link_to_function($name, $function, $urchinUri, $options = array())57 function google_analytics_link_to_function($name, $function, $urchinUri, $options = array()) 58 58 { 59 59 $link = link_to_function($name, $function, $options); 60 60 61 if (sfConfig::get('app_urchin_enabled'))61 if (sfConfig::get('app_google_analytics_enabled')) 62 62 { 63 $link = str_replace('onclick="', 'onclick="urchinTracker(\'' . $urchinUri .'\');', $link);63 $link = str_replace('onclick="', 'onclick="urchinTracker(\''.$urchinUri.'\');', $link); 64 64 } 65 65 plugins/sfGoogleAnalyticsPlugin/trunk/lib/util/sfGoogleAnalyticsToolkit.class.php
r5350 r7189 2 2 3 3 /** 4 * Utility methods for the sf UrchinPlugin.4 * Utility methods for the sfGoogleAnalyticsPlugin. 5 5 * 6 * @package sf UrchinPlugin6 * @package sfGoogleAnalyticsPlugin 7 7 * @subpackage util 8 8 * @author Kris Wallsmith <kris [dot] wallsmith [at] gmail [dot] com> 9 9 * @version SVN: $Id$ 10 10 */ 11 class sf UrchinToolkit11 class sfGoogleAnalyticsToolkit 12 12 { 13 13 /** … … 15 15 * 16 16 * @author Kris Wallsmith 17 * @throws sf UrchinException17 * @throws sfGoogleAnalyticsException 18 18 * 19 19 * @return string … … 28 28 $action = $context->getActionName(); 29 29 30 $actionConfig = sfConfig::get('mod_'.$module.'_'.$action.'_ urchin', array());30 $actionConfig = sfConfig::get('mod_'.$module.'_'.$action.'_google_analytics', array()); 31 31 32 32 $usrc = $request->isSecure() ? 33 sfConfig::get('app_ urchin_usrc_ssl', 'https://ssl.google-analytics.com/urchin.js') :34 sfConfig::get('app_ urchin_usrc', 'http://www.google-analytics.com/urchin.js');33 sfConfig::get('app_google_analytics_usrc_ssl', 'https://ssl.google-analytics.com/urchin.js') : 34 sfConfig::get('app_google_analytics_usrc', 'http://www.google-analytics.com/urchin.js'); 35 35 36 36 // initial parameter … … 42 42 else 43 43 { 44 $utParam = sfConfig::get('app_ urchin_ut_param');45 $utParam = sfConfig::get('mod_'.$module.'_ urchin_ut_param', $utParam);44 $utParam = sfConfig::get('app_google_analytics_ut_param'); 45 $utParam = sfConfig::get('mod_'.$module.'_google_analytics_ut_param', $utParam); 46 46 } 47 47 48 48 // initialization variables 49 $vars = sfConfig::get('app_ urchin_vars', array());50 $vars = array_merge($vars, sfConfig::get('mod_'.$module.'_ urchin_vars', array()));49 $vars = sfConfig::get('app_google_analytics_vars', array()); 50 $vars = array_merge($vars, sfConfig::get('mod_'.$module.'_google_analytics_vars', array())); 51 51 if (isset($actionConfig['vars']) && is_array($actionConfig['vars'])) 52 52 { … … 58 58 { 59 59 // backwards compatibility 60 $vars['uacct'] = sfConfig::get('app_ urchin_uacct');60 $vars['uacct'] = sfConfig::get('app_google_analytics_uacct'); 61 61 if (!$vars['uacct']) 62 62 { 63 throw new sf UrchinException('Please add your Urchinaccount number to your app.yml.');63 throw new sfGoogleAnalyticsException('Please add your Google Analytics account number to your app.yml.'); 64 64 } 65 65 } plugins/sfGoogleAnalyticsPlugin/trunk/package.xml
r5612 r7189 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 2 <package xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" packagerversion="1.4.1" version="2.0" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd"> 3 <name>sf UrchinPlugin</name>3 <name>sfGoogleAnalyticsPlugin</name> 4 4 <channel>pear.symfony-project.com</channel> 5 5 <summary>Easily add Google Analytics.</summary> … … 11 11 <active>yes</active> 12 12 </lead> 13 <date>200 7-10-22</date>13 <date>2008-01-25</date> 14 14 <version> 15 <release> 0.3.1</release>16 <api> 0.3.1</api>15 <release>1.0-RC1</release> 16 <api>1.0-RC1</api> 17 17 </version> 18 18 <stability> 19 <release> beta</release>20 <api> beta</api>19 <release>stable</release> 20 <api>stable</api> 21 21 </stability> 22 22 <license uri="http://www.symfony-project.com/license">MIT license</license> … … 30 30 <dir name="lib"> 31 31 <dir name="action"> 32 <file role="data" name="sf UrchinActionMixin.class.php"/>32 <file role="data" name="sfGoogleAnalyticsActionMixin.class.php"/> 33 33 </dir> 34 34 <dir name="exception"> 35 <file role="data" name="sf UrchinException.class.php"/>35 <file role="data" name="sfGoogleAnalyticsException.class.php"/> 36 36 </dir> 37 37 <dir name="filter"> 38 <file role="data" name="sf UrchinFilter.php"/>38 <file role="data" name="sfGoogleAnalyticsFilter.class.php"/> 39 39 </dir> 40 40 <dir name="helper"> 41 <file role="data" name=" UrchinHelper.php"/>41 <file role="data" name="GoogleAnalyticsHelper.php"/> 42 42 </dir> 43 43 <dir name="util"> 44 <file role="data" name="sf UrchinToolkit.class.php"/>44 <file role="data" name="sfGoogleAnalyticsToolkit.class.php"/> 45 45 </dir> 46 46 </dir>