PiwikTracker::getUrlTrackGoal PHP Method

getUrlTrackGoal() public method

Builds URL to track a goal with idGoal and revenue.
See also: doTrackGoal()
public getUrlTrackGoal ( integer $idGoal, float $revenue ) : string
$idGoal integer Id Goal to record a conversion
$revenue float Revenue for this conversion
return string URL to piwik.php with all parameters set to track the goal conversion
    public function getUrlTrackGoal($idGoal, $revenue = 0.0)
    {
        $url = $this->getRequest($this->idSite);
        $url .= '&idgoal=' . $idGoal;
        if (!empty($revenue)) {
            $revenue = $this->forceDotAsSeparatorForDecimalPoint($revenue);
            $url .= '&revenue=' . $revenue;
        }
        return $url;
    }

Usage Example

/**
 * Helper function to quickly generate the URL to track a goal.
 *
 * @param $idSite
 * @param $idGoal
 * @param float $revenue
 * @return string
 */
function Piwik_getUrlTrackGoal($idSite, $idGoal, $revenue = 0.0)
{
    $tracker = new PiwikTracker($idSite);
    return $tracker->getUrlTrackGoal($idGoal, $revenue);
}