public function getCustomVariable($id, $scope = 'visit')
    {
        if ($scope == 'page') {
            return isset($this->pageCustomVar[$id]) ? $this->pageCustomVar[$id] : false;
        } elseif ($scope == 'event') {
            return isset($this->eventCustomVar[$id]) ? $this->eventCustomVar[$id] : false;
        } else {
            if ($scope != 'visit') {
                throw new Exception("Invalid 'scope' parameter value");
            }
        }
        if (!empty($this->visitorCustomVar[$id])) {
            return $this->visitorCustomVar[$id];
        }
        $cookieDecoded = $this->getCustomVariablesFromCookie();
        if (!is_int($id)) {
            throw new Exception("Parameter to getCustomVariable should be an integer");
        }
        if (!is_array($cookieDecoded)
            || !isset($cookieDecoded[$id])
            || !is_array($cookieDecoded[$id])
            || count($cookieDecoded[$id]) != 2
        ) {
            return false;
        }

        return $cookieDecoded[$id];
    }