Version Notes
Initial release. Easily exclude your browser from Google Analytics tracking, regardless of IP
Download this release
Release Info
Developer | Justin Stern |
Extension | FoxRunSoftware_GoogleAnalyticsExclude |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/community/FoxRunSoftware/GoogleAnalyticsExclude/Adminhtml/Block/System/Config/Google/Ga/Exclude.php +61 -0
- app/code/community/FoxRunSoftware/GoogleAnalyticsExclude/GoogleAnalytics/Helper/Data.php +25 -0
- app/code/community/FoxRunSoftware/GoogleAnalyticsExclude/controllers/Adminhtml/System/Config/Google/GaController.php +76 -0
- app/code/community/FoxRunSoftware/GoogleAnalyticsExclude/etc/config.xml +46 -0
- app/code/community/FoxRunSoftware/GoogleAnalyticsExclude/etc/system.xml +48 -0
- app/etc/modules/FoxRunSoftware_GoogleAnalyticsExclude.xml +9 -0
- package.xml +28 -0
app/code/community/FoxRunSoftware/GoogleAnalyticsExclude/Adminhtml/Block/System/Config/Google/Ga/Exclude.php
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* This is the Google Analytics exclude button.
|
5 |
+
* Note: I just made up this path to contain this file because I thought it
|
6 |
+
* seemed somewhat sensical. This could have gone anywhere within the extension
|
7 |
+
* Adminhtml/Block directory
|
8 |
+
*
|
9 |
+
* @author Justin Stern (www.foxrunsoftware.net)
|
10 |
+
* @copyright Copyright (c) 2012 Justin Stern
|
11 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
12 |
+
*/
|
13 |
+
|
14 |
+
class FoxRunSoftware_GoogleAnalyticsExclude_Adminhtml_Block_System_Config_Google_Ga_Exclude
|
15 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
16 |
+
{
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Generate synchronize button html
|
20 |
+
*
|
21 |
+
* @return string
|
22 |
+
*/
|
23 |
+
protected function _getButtonHtml()
|
24 |
+
{
|
25 |
+
$ga_exclude = Mage::getSingleton('core/cookie')->get('ga_exclude'); // TODO: I would like to make this a constant somewhere, but not sure of the proper 'Magento' way
|
26 |
+
|
27 |
+
if($ga_exclude) {
|
28 |
+
$label = 'Include';
|
29 |
+
$url = Mage::getSingleton('adminhtml/url')->getUrl('*/system_config_google_ga/include',
|
30 |
+
array('store' => $this->getRequest()->getParam('store'),
|
31 |
+
'website' => $this->getRequest()->getParam('website'))); // TODO: not sure whether this is the correct way to grab the Current Configuration Scope
|
32 |
+
} else {
|
33 |
+
$label = 'Exclude';
|
34 |
+
$url = Mage::getSingleton('adminhtml/url')->getUrl('*/system_config_google_ga/exclude',
|
35 |
+
array('store' => $this->getRequest()->getParam('store'),
|
36 |
+
'website' => $this->getRequest()->getParam('website')));
|
37 |
+
}
|
38 |
+
|
39 |
+
$button = $this->getLayout()->createBlock('adminhtml/widget_button')
|
40 |
+
->setData(array(
|
41 |
+
'label' => $this->__($label),
|
42 |
+
'onclick' => "window.location.href='{$url}'"
|
43 |
+
));
|
44 |
+
|
45 |
+
return $button->toHtml();
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Seems a little odd to have to override this function, when the parameter
|
50 |
+
* passed in is Varien_Data_Form_Element_Button, but that seems to create
|
51 |
+
* a standard browser button, when what I want is the fancy Magento widget
|
52 |
+
* button, and maybe there's no Varien_Data_Form_Element_Abstract for that
|
53 |
+
*/
|
54 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
|
55 |
+
|
56 |
+
$this->setElement($element);
|
57 |
+
|
58 |
+
return $this->_getButtonHtml();
|
59 |
+
}
|
60 |
+
|
61 |
+
}
|
app/code/community/FoxRunSoftware/GoogleAnalyticsExclude/GoogleAnalytics/Helper/Data.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* GoogleAnalytics data helper
|
5 |
+
*
|
6 |
+
* @author Justin Stern (www.foxrunsoftware.net)
|
7 |
+
* @copyright Copyright (c) 2012 Justin Stern
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*
|
10 |
+
* @category FoxRunSoftware
|
11 |
+
* @package FoxRunSoftware_GoogleAnalyticsExclude
|
12 |
+
*/
|
13 |
+
class FoxRunSoftware_GoogleAnalyticsExclude_GoogleAnalytics_Helper_Data extends Mage_GoogleAnalytics_Helper_Data
|
14 |
+
{
|
15 |
+
/**
|
16 |
+
* Whether GA is ready to use
|
17 |
+
*
|
18 |
+
* @param mixed $store
|
19 |
+
* @return bool
|
20 |
+
*/
|
21 |
+
public function isGoogleAnalyticsAvailable($store = null)
|
22 |
+
{
|
23 |
+
return parent::isGoogleAnalyticsAvailable($store) && !Mage::getSingleton('core/cookie')->get('ga_exclude');
|
24 |
+
}
|
25 |
+
}
|
app/code/community/FoxRunSoftware/GoogleAnalyticsExclude/controllers/Adminhtml/System/Config/Google/GaController.php
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Adminhtml account controller
|
5 |
+
*
|
6 |
+
* @author Justin Stern (www.foxrunsoftware.net)
|
7 |
+
* @copyright Copyright (c) 2012 Justin Stern
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*
|
10 |
+
* @category Mage
|
11 |
+
* @package Mage_Adminhtml
|
12 |
+
*/
|
13 |
+
class FoxRunSoftware_GoogleAnalyticsExclude_Adminhtml_System_Config_Google_GaController
|
14 |
+
extends Mage_Adminhtml_Controller_Action
|
15 |
+
{
|
16 |
+
/**
|
17 |
+
* Set the ga_exclude cookie, to exclude this browser from Google Analytics
|
18 |
+
*
|
19 |
+
* @return void
|
20 |
+
*/
|
21 |
+
public function excludeAction()
|
22 |
+
{
|
23 |
+
// set or renew the cookie
|
24 |
+
// TODO: this assumes the host of the admin matches that of the store. What
|
25 |
+
// would we do for a Magento with multiple stores, and for the different
|
26 |
+
// configuration scopes?
|
27 |
+
Mage::getSingleton('core/cookie')->set('ga_exclude',1,3600 * 24 * 365 * 5,'/',null,false);
|
28 |
+
|
29 |
+
$this->_saveState();
|
30 |
+
|
31 |
+
$this->_redirectToGoogleConfig();
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Remove the ga_exclude cookie, to include this browser in Google Analytics
|
36 |
+
*
|
37 |
+
* @return void
|
38 |
+
*/
|
39 |
+
public function includeAction()
|
40 |
+
{
|
41 |
+
// delete the cookie
|
42 |
+
Mage::getSingleton('core/cookie')->delete('ga_exclude');
|
43 |
+
|
44 |
+
$this->_saveState();
|
45 |
+
|
46 |
+
$this->_redirectToGoogleConfig();
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Redirect back to the admin system configuration Google edit screen
|
51 |
+
*/
|
52 |
+
protected function _redirectToGoogleConfig() {
|
53 |
+
// TODO: not sure whether this is the proper way grab the current configuration scope
|
54 |
+
$this->_redirect('*/system_config/edit', array('section' => 'google',
|
55 |
+
'store' => $this->getRequest()->getParam('store'),
|
56 |
+
'website' => $this->getRequest()->getParam('website')));
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Mark the Google Analytics fieldset as not-collapsed
|
61 |
+
*/
|
62 |
+
protected function _saveState() {
|
63 |
+
$adminUser = Mage::getSingleton('admin/session')->getUser();
|
64 |
+
$extra = $adminUser->getExtra();
|
65 |
+
|
66 |
+
if (!is_array($extra)) {
|
67 |
+
$extra = array();
|
68 |
+
}
|
69 |
+
if (!isset($extra['configState'])) {
|
70 |
+
$extra['configState'] = array();
|
71 |
+
}
|
72 |
+
$extra['configState']['google_analytics'] = 1; // not sure whether there is a 'proper' place to grab the string 'google_analytics' from
|
73 |
+
|
74 |
+
$adminUser->saveExtra($extra);
|
75 |
+
}
|
76 |
+
}
|
app/code/community/FoxRunSoftware/GoogleAnalyticsExclude/etc/config.xml
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* @author Justin Stern (www.foxrunsoftware.net)
|
5 |
+
* @copyright Copyright (c) 2012 Justin Stern
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*
|
8 |
+
* @package FoxRunSoftware_GoogleAnalyticsExclude
|
9 |
+
*/
|
10 |
+
-->
|
11 |
+
<config>
|
12 |
+
<modules>
|
13 |
+
<FoxRunSoftware_GoogleAnalyticsExclude>
|
14 |
+
<version>1.0.0</version>
|
15 |
+
</FoxRunSoftware_GoogleAnalyticsExclude>
|
16 |
+
</modules>
|
17 |
+
<global>
|
18 |
+
<blocks>
|
19 |
+
<adminhtml>
|
20 |
+
<rewrite>
|
21 |
+
<!-- not technically rewriting, just adding, but this is how you do it -->
|
22 |
+
<system_config_google_ga_exclude>FoxRunSoftware_GoogleAnalyticsExclude_Adminhtml_Block_System_Config_Google_Ga_Exclude</system_config_google_ga_exclude>
|
23 |
+
</rewrite>
|
24 |
+
</adminhtml>
|
25 |
+
</blocks>
|
26 |
+
<helpers>
|
27 |
+
<googleanalytics>
|
28 |
+
<rewrite>
|
29 |
+
<data>FoxRunSoftware_GoogleAnalyticsExclude_GoogleAnalytics_Helper_Data</data>
|
30 |
+
</rewrite>
|
31 |
+
</googleanalytics>
|
32 |
+
</helpers>
|
33 |
+
</global>
|
34 |
+
<admin>
|
35 |
+
<routers>
|
36 |
+
<adminhtml>
|
37 |
+
<args>
|
38 |
+
<modules>
|
39 |
+
<!-- Hook up the controller -->
|
40 |
+
<FoxRunSoftware_GoogleAnalyticsExclude>FoxRunSoftware_GoogleAnalyticsExclude_Adminhtml</FoxRunSoftware_GoogleAnalyticsExclude>
|
41 |
+
</modules>
|
42 |
+
</args>
|
43 |
+
</adminhtml>
|
44 |
+
</routers>
|
45 |
+
</admin>
|
46 |
+
</config>
|
app/code/community/FoxRunSoftware/GoogleAnalyticsExclude/etc/system.xml
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* @author Justin Stern (www.foxrunsoftware.net)
|
5 |
+
* @copyright Copyright (c) 2012 Justin Stern
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*
|
8 |
+
* @package FoxRunSoftware_GoogleAnalyticsExclude
|
9 |
+
*/
|
10 |
+
-->
|
11 |
+
<config>
|
12 |
+
<sections>
|
13 |
+
<google>
|
14 |
+
<!-- Started out by copying the existing google analytics system.xml file, but I guess the following commented-out section is not needed, as we are adding to an existing section -->
|
15 |
+
<!--
|
16 |
+
<label>Google API</label>
|
17 |
+
<tab>sales</tab>
|
18 |
+
<frontend_type>text</frontend_type>
|
19 |
+
<sort_order>340</sort_order>
|
20 |
+
<show_in_default>1</show_in_default>
|
21 |
+
<show_in_website>1</show_in_website>
|
22 |
+
<show_in_store>1</show_in_store -->
|
23 |
+
<groups>
|
24 |
+
<analytics>
|
25 |
+
<!--
|
26 |
+
<label>Google Analytics</label>
|
27 |
+
<frontend_type>text</frontend_type>
|
28 |
+
<sort_order>10</sort_order>
|
29 |
+
<show_in_default>1</show_in_default>
|
30 |
+
<show_in_website>1</show_in_website>
|
31 |
+
<show_in_store>1</show_in_store -->
|
32 |
+
<fields>
|
33 |
+
<test translate="label comment">
|
34 |
+
<label>Exclude This Browser</label>
|
35 |
+
<comment>Toggles a cookie in this browser, which when enabled suppresses the client-side Google Analytics code. Make sure to enable this on *all* browsers you use to access the site, and re-enable if you clear your cookies.</comment>
|
36 |
+
<frontend_type>button</frontend_type>
|
37 |
+
<frontend_model>adminhtml/system_config_google_ga_exclude</frontend_model> <!-- This is actually a block -->
|
38 |
+
<sort_order>21</sort_order>
|
39 |
+
<show_in_default>1</show_in_default>
|
40 |
+
<show_in_website>1</show_in_website>
|
41 |
+
<show_in_store>1</show_in_store>
|
42 |
+
</test>
|
43 |
+
</fields>
|
44 |
+
</analytics>
|
45 |
+
</groups>
|
46 |
+
</google>
|
47 |
+
</sections>
|
48 |
+
</config>
|
app/etc/modules/FoxRunSoftware_GoogleAnalyticsExclude.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<FoxRunSoftware_GoogleAnalyticsExclude>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
</FoxRunSoftware_GoogleAnalyticsExclude>
|
8 |
+
</modules>
|
9 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>FoxRunSoftware_GoogleAnalyticsExclude</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Easily stop your computer from appearing in Google Analytics for your Magento store, even with a dynamic IP.</summary>
|
10 |
+
<description><h2>Overview</h2>
|
11 |
+
<p>Control whether your computer is tracked by Google Analytics, regardless of your IP. This extension sets a cookie which excludes that browser from rendering the Google Analytics tracking code. Great for small sites/stores where your activity could create misleading Analytics reports and you can't/don't have a static IP to filter in the normal method.</p>
|
12 |
+

|
13 |
+
<h2>Features</h2>
|
14 |
+
<ul>
|
15 |
+
<li>Adds an admin configuration control 'Exclude This Browser' integrated into System > Configuration > Sales - Google API > Google Analytics. Enabling this sets a long-term cookie in the browser, which when turned on disables the client side Google Analytics tracking call.</li>
|
16 |
+
<li>Compatible with the popular and recommended Fooman GoogleAnalyticsPlus extension.</li>
|
17 |
+
</ul>
|
18 |
+

|
19 |
+
<h2>Notes</h2>
|
20 |
+
<p>Has not been tested with multi-website/store installations</p> </description>
|
21 |
+
<notes>Initial release. Easily exclude your browser from Google Analytics tracking, regardless of IP</notes>
|
22 |
+
<authors><author><name>Justin Stern</name><user>foxrunsoftware</user><email>justin@foxrunsoftware.net</email></author></authors>
|
23 |
+
<date>2012-01-30</date>
|
24 |
+
<time>02:38:08</time>
|
25 |
+
<contents><target name="magecommunity"><dir name="FoxRunSoftware"><dir name="GoogleAnalyticsExclude"><dir name="Adminhtml"><dir name="Block"><dir name="System"><dir name="Config"><dir name="Google"><dir name="Ga"><file name="Exclude.php" hash="23dc8be791aef4795048a16acd95bf7f"/></dir></dir></dir></dir></dir></dir><dir name="GoogleAnalytics"><dir name="Helper"><file name="Data.php" hash="888304caf55eb5d33164dcec792ea566"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Google"><file name="GaController.php" hash="b8bd9eebec68abd676042111ff4215d7"/></dir></dir></dir></dir></dir><dir name="etc"><file name="config.xml" hash="20572746dbbbc3dedcf5be57428a21f5"/><file name="system.xml" hash="966a81cf7816529610caff60161a4705"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="FoxRunSoftware_GoogleAnalyticsExclude.xml" hash="80c4ebb3095acd4bf1a6df7052908595"/></dir></target></contents>
|
26 |
+
<compatible/>
|
27 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
28 |
+
</package>
|