Skip to content

Commit

Permalink
Create a configuration option to turn off tracking
Browse files Browse the repository at this point in the history
In development/staging environments you can now turn off tracking
by a configuration variable in your local.php autoload config file.
  • Loading branch information
Jurian Sluiman committed Apr 29, 2013
1 parent a0debaa commit 8bee68c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ public function getServiceConfig()
$tracker->setAllowLinker($config['allow_linker']);
}

if (false === $config['enable']) {
$tracker->setEnableTracking(false);
}

return $tracker;
},
),
Expand Down
1 change: 1 addition & 0 deletions config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

return array(
'google_analytics' => array(
'enable' => true,
'id' => '',
'domain_name' => '',
'allow_linker' => false,
Expand Down
9 changes: 9 additions & 0 deletions config/slmgoogleanalytics.global.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ $googleAnalytics = array(
*/
'domain_name' => '',
'allow_linker' => false,

/**
* Disable/enable page tracking
*
* It is adviced to turn off tracking in a development/staging environment. Put this
* configuration option in your local.php in the autoload folder and set "enable" to
* false.
*/
// 'enable' => false,
);

/**
Expand Down
6 changes: 3 additions & 3 deletions src/SlmGoogleAnalytics/Analytics/Tracker.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function setEnablePageTracking ($enable_page_tracking = true)
{
$this->enablePageTracking = (bool) $enable_page_tracking;
}

public function setAllowLinker($allow_linker)
{
$this->allowLinker = (bool) $allow_linker;
Expand All @@ -120,7 +120,7 @@ public function setDomainName($domain_name)
{
if (!is_string($domain_name))
throw new InvalidArgumentException('$domain_name is not a string');

$this->domainName = $domain_name;
}

Expand All @@ -143,7 +143,7 @@ public function setAnonymizeIp($flag)
{
$this->anonymizeIp = (bool) $flag;
}

public function events ()
{
return $this->events;
Expand Down

0 comments on commit 8bee68c

Please sign in to comment.