开发者

Serverside Google Analytics without Zend - how?

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('Refe开发者_Go百科rer', "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;
    }


You should be able to convert that to curl quite easily.

Curl is basically.

  1. get a curl handler
  2. configure the request through the handler
  3. do the request and grab the result if you need

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/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜