diff --git a/src/PiwikTwigExtension.php b/src/PiwikTwigExtension.php index 94d9943..ae91ec0 100644 --- a/src/PiwikTwigExtension.php +++ b/src/PiwikTwigExtension.php @@ -60,6 +60,10 @@ public function getFunctions() */ public function generatePiwikTrackerCode($piwikHost = null, $siteId = null) { + if (! $this->enabled) { + return ''; + } + $piwikHost = $piwikHost ?: $this->piwikHost; $siteId = $siteId ?: $this->siteId; @@ -70,11 +74,6 @@ public function generatePiwikTrackerCode($piwikHost = null, $siteId = null) throw new InvalidArgumentException('No Piwik site ID was configured or given to generate the tracker code'); } - // Check only now so that exceptions are still thrown in dev environment - if (! $this->enabled) { - return ''; - } - $piwikHost = rtrim($piwikHost, '/'); $code = <<