thomasbachem / php-ga Goto Github PK
View Code? Open in Web Editor NEWServer-Side Google Analytics PHP Client
License: Other
Server-Side Google Analytics PHP Client
License: Other
Last commit is from November 2015, there are 8 pull requests open. Has the library been abandoned?
Is it possible to make full or partial refund with this lib?
Hi,
I am using PHP-GA client to track my website page views, event and custom variable tracking. it's working good with out any issues for last three months.
but now, some times i got the following error, when i view my tracking url.
fsockopen(): unable to connect to www.google-analytics.com:80 (Connection timed out) (/php-ga-1.1.1/src/GoogleAnalytics/Internals/Request/HttpRequest.php:183)
Environment: Pagodabox
Composer.json:
"united-prototype/php-ga": "dev-composer",
On push to server, composer errors out like so:
- Failed to clone https://github.com/Fran6co/php-ga.git via git, https protocols, aborting.
-
- - git://github.com/Fran6co/php-ga.git
- fatal: remote error:
- Repository not found.
-
- - https://github.com/Fran6co/php-ga.git
- error: The requested URL returned error: 403 while accessing https://github.com/Fran6co/php-ga.git/info/refs
-
- fatal: HTTP request failed
Ive implemented this for mp3 files which works great, but im also including the mp3's on the site in the default html audio player. This no longer works with the added tracking to all mp3 files. Any fix I could do to exclude requests coming from the same server or similar?
thanks
How we send info if the user come from social networks? for example if user clicks shared link in facebook, how works php-ga in that time, can it send information about the click?
Hi,
I'm working on a project to implement Enhanced Ecommerce. We want to use this library to also register the ordered products through our API and I'm wondering if this library also supports Enhanced Ecommerce instead of Ecommerce.
Thanks in advance!
Sven Buijsrogge
I'm using Php-ga for a tinyurl redirect service and i'm having problems passing on the referrer data to G.A. (utmr=facebook f.e....).
After looking into it, Php ga builds the correct object right till the HTTP Request to Google with the proper parameter set ("utmr=refer_x"), but then it just doesn't show up on G.A.!
Setting this referrer variable into any other G.A. parameter (f.e. Page title) will be displayed successfully..
Any one experienced such problem?
Many thanks
it's a great library, just implemented it for our xml-newsfeed transported to a Mac App.
Biggest step was to implement the returning visitor count.
Now this is either a feature request for php-ga or for it's documentation:
Why would I have to do the increment of returning visits in my code? Why isn't this done inside tracker?
Now:
$isNewVisitor = true;
if ($_COOKIE['__utma']) {
$visitor->fromUtma($_COOKIE['__utma']);
$isNewVisitor = false;
}
if($isNewVisitor) {
// all defaults are set when Visitor is inited
// dont know how to get account hash from tracker...
// $utmaContent = array( '217597461', $visitor->getUniqueId(), $visitor->getFirstVisitTime()->getTimeStamp(), $visitor->getPreviousVisitTime()->getTimeStamp(), $visitor->getCurrentVisitTime()->getTimeStamp(), $visitor->getVisitCount());
} else {
$visitor->setVisitCount( $visitor->getVisitCount() + 1);
}
$utmaContent = array( '217597461', $visitor->getUniqueId(), $visitor->getFirstVisitTime()->getTimeStamp(), $visitor->getPreviousVisitTime()->getTimeStamp(), $visitor->getCurrentVisitTime()->getTimeStamp(), $visitor->getVisitCount());
$utmaContent = implode('.', $utmaContent);
$cookieSet = setcookie('__utma', $utmaContent, strtotime('+2 years'));
New:
The attached patch adds simple http proxy support.
diff --git a/php-ga/src/GoogleAnalytics/Config.php b/php-ga/src/GoogleAnalytics/Config.php
index 7f19142..c0b51f0 100644
--- a/php-ga/src/GoogleAnalytics/Config.php
+++ b/php-ga/src/GoogleAnalytics/Config.php
@@ -113,6 +113,14 @@ class Config {
* @var string
*/
protected $endPointHost = 'www.google-analytics.com';
+
+ /**
+ * Connect to $endPointHost through this proxy
+ *
+ * @see Internals\Request\HttpRequest::send()
+ * @var string
+ */
+ protected $httpProxy = null;
/**
* Google Analytics tracking request endpoint path
@@ -290,6 +298,21 @@ class Config {
$this->sitespeedSampleRate = (int)$sitespeedSampleRate;
}
+ /**
+ * @return string
+ */
+ public function getHttpProxy() {
+ return $this->httpProxy;
+ }
+
+ /**
+ * @param string $host
+ * @param int $port
+ */
+ public function setHttpProxy($host, $port) {
+ $this->httpProxy = sprintf('%s:%d', $host, $port);
+ }
+
}
?>
\ No newline at end of file
diff --git a/php-ga/src/GoogleAnalytics/Internals/Request/HttpRequest.php b/php-ga/src/GoogleAnalytics/Internals/Request/HttpRequest.php
index 2ba81ae..60bf47a 100644
--- a/php-ga/src/GoogleAnalytics/Internals/Request/HttpRequest.php
+++ b/php-ga/src/GoogleAnalytics/Internals/Request/HttpRequest.php
@@ -121,10 +121,10 @@ abstract class HttpRequest {
$usePost = strlen($queryString) > 2036;
if(!$usePost) {
- $r = 'GET ' . $this->config->getEndpointPath() . '?' . $queryString . ' HTTP/1.0' . "\r\n";
+ $r = 'GET ' . "http://" . $this->config->getEndpointHost() . $this->config->getEndpointPath() . '?' . $queryString . ' HTTP/1.0' . "\r\n";
} else {
// FIXME: The "/p" shouldn't be hardcoded here, instead we need a GET and a POST endpoint...
- $r = 'POST /p' . $this->config->getEndpointPath() . ' HTTP/1.0' . "\r\n";
+ $r = 'POST ' . "http://" . $this->config->getEndpointHost() . "/p" . $this->config->getEndpointPath() . ' HTTP/1.0' . "\r\n";
}
$r .= 'Host: ' . $this->config->getEndpointHost() . "\r\n";
@@ -180,7 +180,14 @@ abstract class HttpRequest {
if($this->config->getEndpointHost() !== null) {
$timeout = $this->config->getRequestTimeout();
- $socket = fsockopen($this->config->getEndpointHost(), 80, $errno, $errstr, $timeout);
+ $proxy = $this->config->getHttpProxy();
+ if ($proxy) {
+ list($host, $port) = explode(':', $proxy);
+ } else {
+ $host = $this->config->getEndpointHost();
+ $port = 80;
+ }
+ $socket = fsockopen($host, $port, $errno, $errstr, $timeout);
if(!$socket) return false;
if($this->config->getFireAndForget()) {
I look at track.php set parameter page = null, but that method still display error. If I get something wrong. Can you advice me, please?
Hi
active visitors increase with each call to autoload.php.
Is this something that need to be corrected server side?
Hi. I get some bug.. I get script, set all params and start track well. All visitors count by them. By if I change default line
$page = new GoogleAnalytics\Page("/page.html");
to something, like
$page = new GoogleAnalytics\Page("/page2.html");
All page count will stop. I trace all params and all be work well — to GA send param '/page2.html'. But on online page i dont see all new visitors
On screenshot example of this moment.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.