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];
    }
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];
    }
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 ] ; }
Returns the currently assigned Custom Variable.

If scope is 'visit', it will attempt to read the value set in the first party cookie created by Piwik Tracker
($_COOKIE array).

@param int $id Custom Variable integer index to fetch from cookie. Should be a value from 1 to 5
@param string $scope Custom variable scope. Possible values: visit, page, event

@throws Exception
@return mixed An array with this format: array( 0 => CustomVariableName, 1 => CustomVariableValue ) or false
@see Piwik.js getCustomVariable()
Returns the currently assigned Custom Variable .