diff --git a/src/ScriptViewCreator.php b/src/ScriptViewCreator.php index 1ed9a62..8fc5f0b 100644 --- a/src/ScriptViewCreator.php +++ b/src/ScriptViewCreator.php @@ -27,13 +27,14 @@ public function __construct(GoogleTagManager $googleTagManager) */ public function create(View $view) { - if ($this->googleTagManager->isEnabled() && empty($this->googleTagManager->id())) { + $id = $this->googleTagManager->id(); + if ($this->googleTagManager->isEnabled() && empty($id)) { throw new ApiKeyNotSetException(); } $view ->with('enabled', $this->googleTagManager->isEnabled()) - ->with('id', $this->googleTagManager->id()) + ->with('id', $id) ->with('dataLayer', $this->googleTagManager->getDataLayer()); } }