Reputation: 901
I'm using a basic URL shortening script for one of my sites so that I can manage the URLs internally (and have less trailing characters on the urls). It's working well, but I'd like to be able to use Google Analytics to track the clicks.
I've found this: http://code.google.com/p/serversidegoogleanalytics/ which seems to achieve this using events, but I'm not using Zend. It mentions using curl to customise it, but without any knowledge of curl, would it simply be a case of amending this function from within the class:
public function getHttpClient () {
if(!$this->httpClient instanceof Zend_Http_Client) {
include_once("Zend/Http/Client.php");
$this->httpClient = new Zend_Http_Client();
$this->httpClient->setConfig(array(
'maxredirects' => 1,
'timeout' => 4
));
$this->httpClient->setHeaders('Referer', "http://" . self::$trackingDomain . "/");
$this->httpClient->setHeaders("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.7) Gecko/2009021910 Firefox/3.0.7 (.NET CLR 3.5.30729)");
$this->httpClient->setCookieJar();
}
return $this->httpClient;
}
Upvotes: 0
Views: 553
Reputation: 21249
You should be able to convert that to curl quite easily.
Curl is basically.
Check out the examples page, it's pretty simple
http://au.php.net/manual/en/curl.examples-basic.php
EDIT: there's even examples of Analytics with curl on google..
http://www.electrictoolbox.com/google-analytics-login-php-curl-username-password/
Upvotes: 1