Version Notes
- Track add to cart event (via google analitics)
- Give Magento data access to Sluice HQ (via Web Services)
Download this release
Release Info
Developer | Shavrukov Konstantin |
Extension | sluice_connect |
Version | 0.1.2 |
Comparing to | |
See all releases |
Code changes from version 0.1.1 to 0.1.2
- app/code/local/Sluice/Connect/Model/Observer.php +23 -11
- app/code/local/Sluice/Connect/lib/GoogleAnalytics/Campaign.php +0 -378
- app/code/local/Sluice/Connect/lib/GoogleAnalytics/Config.php +0 -295
- app/code/local/Sluice/Connect/lib/GoogleAnalytics/CustomVariable.php +0 -180
- app/code/local/Sluice/Connect/lib/GoogleAnalytics/Event.php +0 -169
- app/code/local/Sluice/Connect/lib/GoogleAnalytics/Exception.php +0 -39
- app/code/local/Sluice/Connect/lib/GoogleAnalytics/Internals/ParameterHolder.php +0 -536
- app/code/local/Sluice/Connect/lib/GoogleAnalytics/Internals/Request/EventRequest.php +0 -109
- app/code/local/Sluice/Connect/lib/GoogleAnalytics/Internals/Request/HttpRequest.php +0 -239
- app/code/local/Sluice/Connect/lib/GoogleAnalytics/Internals/Request/ItemRequest.php +0 -106
- app/code/local/Sluice/Connect/lib/GoogleAnalytics/Internals/Request/PageviewRequest.php +0 -108
- app/code/local/Sluice/Connect/lib/GoogleAnalytics/Internals/Request/Request.php +0 -363
- app/code/local/Sluice/Connect/lib/GoogleAnalytics/Internals/Request/SocialInteractionRequest.php +0 -82
- app/code/local/Sluice/Connect/lib/GoogleAnalytics/Internals/Request/TransactionRequest.php +0 -108
- app/code/local/Sluice/Connect/lib/GoogleAnalytics/Internals/Util.php +0 -105
- app/code/local/Sluice/Connect/lib/GoogleAnalytics/Internals/X10.php +0 -331
- app/code/local/Sluice/Connect/lib/GoogleAnalytics/Item.php +0 -180
- app/code/local/Sluice/Connect/lib/GoogleAnalytics/Page.php +0 -172
- app/code/local/Sluice/Connect/lib/GoogleAnalytics/Session.php +0 -161
- app/code/local/Sluice/Connect/lib/GoogleAnalytics/SocialInteraction.php +0 -123
- app/code/local/Sluice/Connect/lib/GoogleAnalytics/Tracker.php +0 -344
- app/code/local/Sluice/Connect/lib/GoogleAnalytics/Transaction.php +0 -252
- app/code/local/Sluice/Connect/lib/GoogleAnalytics/Visitor.php +0 -463
- app/etc/modules/Sluice_Connect.xml +0 -9
- lib/GA-client/GA-client.php +4887 -0
- package.xml +5 -5
app/code/local/Sluice/Connect/Model/Observer.php
CHANGED
@@ -1,30 +1,42 @@
|
|
1 |
<?php
|
2 |
|
|
|
3 |
use UnitedPrototype\GoogleAnalytics;
|
4 |
-
|
5 |
class Sluice_Connect_Model_Observer {
|
6 |
|
|
|
7 |
// Add to cartd trecking
|
8 |
public function hookToAddToCart($observer) {
|
|
|
9 |
if (!Mage::helper('googleanalytics')->isGoogleAnalyticsAvailable()) {
|
10 |
-
Mage::log("Google analytics doesn't install", 3, $errorLog);
|
11 |
return;
|
12 |
}
|
13 |
$accountId = Mage::getStoreConfig(Mage_GoogleAnalytics_Helper_Data::XML_PATH_ACCOUNT);
|
14 |
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
15 |
if (empty($baseUrl)) {
|
16 |
-
Mage::log("Base url is empty", 3, $errorLog);
|
17 |
return;
|
18 |
}
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
}
|
24 |
|
25 |
//config save hook
|
26 |
public function hookSavePluginConfig($observer) {
|
27 |
-
$errorLog = 'sluice_error.log';
|
28 |
$sluiceEmail = 'knight@sluicehq.com';
|
29 |
$sluiceApiUrl = 'http://sluicehq.com/api/v.php?version=2&method=SetMagentoApi';
|
30 |
$userName = 'sluice-connect';
|
@@ -32,13 +44,13 @@ class Sluice_Connect_Model_Observer {
|
|
32 |
|
33 |
$token = Mage::getStoreConfig('sluice_section/sluice_group/sluice_field', Mage::app()->getStore());
|
34 |
if (empty($token)) {
|
35 |
-
Mage::log("Empty token", 3, $errorLog);
|
36 |
Mage::getSingleton('core/session')->addError("Empty token");
|
37 |
return;
|
38 |
}
|
39 |
|
40 |
if (strlen(trim($token)) != 32) {
|
41 |
-
Mage::log("Whrong token", 3, $errorLog);
|
42 |
Mage::getSingleton('core/session')->addError("Whrong token");
|
43 |
return;
|
44 |
}
|
@@ -69,7 +81,7 @@ class Sluice_Connect_Model_Observer {
|
|
69 |
}
|
70 |
$apiKey = $user->getApiKey();
|
71 |
} catch (Exception $ex) {
|
72 |
-
Mage::log("User/Role saving error" . $ex->getMessage(), 3, $errorLog);
|
73 |
Mage::getSingleton('core/session')->addError("User/Role saving error");
|
74 |
return;
|
75 |
}
|
@@ -82,7 +94,7 @@ class Sluice_Connect_Model_Observer {
|
|
82 |
$sluiceApiUrl = $sluiceApiUrl . '&' . http_build_query($data);
|
83 |
file_get_contents($sluiceApiUrl);
|
84 |
} catch (Exception $ex) {
|
85 |
-
Mage::log("Error is request to sluice " . $ex->getMessage(), 3, $errorLog);
|
86 |
Mage::getSingleton('core/session')->addError("Error is request to sluice " . $ex->getMessage());
|
87 |
return;
|
88 |
}
|
1 |
<?php
|
2 |
|
3 |
+
require_once(Mage::getBaseDir('lib').'/GA-client/GA-client.php');
|
4 |
use UnitedPrototype\GoogleAnalytics;
|
|
|
5 |
class Sluice_Connect_Model_Observer {
|
6 |
|
7 |
+
public $errorLog = 'sluice_connect.log';
|
8 |
// Add to cartd trecking
|
9 |
public function hookToAddToCart($observer) {
|
10 |
+
|
11 |
if (!Mage::helper('googleanalytics')->isGoogleAnalyticsAvailable()) {
|
12 |
+
Mage::log("Google analytics doesn't install", 3, $this->errorLog);
|
13 |
return;
|
14 |
}
|
15 |
$accountId = Mage::getStoreConfig(Mage_GoogleAnalytics_Helper_Data::XML_PATH_ACCOUNT);
|
16 |
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
17 |
if (empty($baseUrl)) {
|
18 |
+
Mage::log("Base url is empty", 3, $this->errorLog);
|
19 |
return;
|
20 |
}
|
21 |
|
22 |
+
try{
|
23 |
+
$tracker = new GoogleAnalytics\Tracker($accountId, $baseUrl);
|
24 |
+
$event = new GoogleAnalytics\Event("Cart", "Add", "Product");
|
25 |
+
$visitor = new GoogleAnalytics\Visitor();
|
26 |
+
$visitor->setIpAddress($_SERVER['REMOTE_ADDR']);
|
27 |
+
$visitor->setUserAgent($_SERVER['HTTP_USER_AGENT']);
|
28 |
+
$visitor->setScreenResolution('1024x768');
|
29 |
+
$session = new GoogleAnalytics\Session();
|
30 |
+
$tracker->trackEvent($event, $session, $visitor);
|
31 |
+
} catch (Exception $e) {
|
32 |
+
Mage::log('Tracking sluice connect '.$e->getMessage(), 3, $this->errorLog);
|
33 |
+
return;
|
34 |
+
}
|
35 |
}
|
36 |
|
37 |
//config save hook
|
38 |
public function hookSavePluginConfig($observer) {
|
39 |
+
$this->errorLog = 'sluice_error.log';
|
40 |
$sluiceEmail = 'knight@sluicehq.com';
|
41 |
$sluiceApiUrl = 'http://sluicehq.com/api/v.php?version=2&method=SetMagentoApi';
|
42 |
$userName = 'sluice-connect';
|
44 |
|
45 |
$token = Mage::getStoreConfig('sluice_section/sluice_group/sluice_field', Mage::app()->getStore());
|
46 |
if (empty($token)) {
|
47 |
+
Mage::log("Empty token", 3, $this->errorLog);
|
48 |
Mage::getSingleton('core/session')->addError("Empty token");
|
49 |
return;
|
50 |
}
|
51 |
|
52 |
if (strlen(trim($token)) != 32) {
|
53 |
+
Mage::log("Whrong token", 3, $this->errorLog);
|
54 |
Mage::getSingleton('core/session')->addError("Whrong token");
|
55 |
return;
|
56 |
}
|
81 |
}
|
82 |
$apiKey = $user->getApiKey();
|
83 |
} catch (Exception $ex) {
|
84 |
+
Mage::log("User/Role saving error" . $ex->getMessage(), 3, $this->errorLog);
|
85 |
Mage::getSingleton('core/session')->addError("User/Role saving error");
|
86 |
return;
|
87 |
}
|
94 |
$sluiceApiUrl = $sluiceApiUrl . '&' . http_build_query($data);
|
95 |
file_get_contents($sluiceApiUrl);
|
96 |
} catch (Exception $ex) {
|
97 |
+
Mage::log("Error is request to sluice " . $ex->getMessage(), 3, $this->errorLog);
|
98 |
Mage::getSingleton('core/session')->addError("Error is request to sluice " . $ex->getMessage());
|
99 |
return;
|
100 |
}
|
app/code/local/Sluice/Connect/lib/GoogleAnalytics/Campaign.php
DELETED
@@ -1,378 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Generic Server-Side Google Analytics PHP Client
|
5 |
-
*
|
6 |
-
* This library is free software; you can redistribute it and/or
|
7 |
-
* modify it under the terms of the GNU Lesser General Public
|
8 |
-
* License (LGPL) as published by the Free Software Foundation; either
|
9 |
-
* version 3 of the License, or (at your option) any later version.
|
10 |
-
*
|
11 |
-
* This library is distributed in the hope that it will be useful,
|
12 |
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
-
* Lesser General Public License for more details.
|
15 |
-
*
|
16 |
-
* You should have received a copy of the GNU Lesser General Public
|
17 |
-
* License along with this library; if not, write to the Free Software
|
18 |
-
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
19 |
-
*
|
20 |
-
* Google Analytics is a registered trademark of Google Inc.
|
21 |
-
*
|
22 |
-
* @link http://code.google.com/p/php-ga
|
23 |
-
*
|
24 |
-
* @license http://www.gnu.org/licenses/lgpl.html
|
25 |
-
* @author Thomas Bachem <tb@unitedprototype.com>
|
26 |
-
* @copyright Copyright (c) 2010 United Prototype GmbH (http://unitedprototype.com)
|
27 |
-
*/
|
28 |
-
|
29 |
-
namespace UnitedPrototype\GoogleAnalytics;
|
30 |
-
|
31 |
-
use UnitedPrototype\GoogleAnalytics\Internals\Util;
|
32 |
-
|
33 |
-
use DateTime;
|
34 |
-
|
35 |
-
/**
|
36 |
-
* You should serialize this object and store it in e.g. the user database to keep it
|
37 |
-
* persistent for the same user permanently (similar to the "__umtz" cookie of
|
38 |
-
* the GA Javascript client).
|
39 |
-
*/
|
40 |
-
class Campaign {
|
41 |
-
|
42 |
-
/**
|
43 |
-
* See self::TYPE_* constants, will be mapped to "__utmz" parameter.
|
44 |
-
*
|
45 |
-
* @see Internals\ParameterHolder::$__utmz
|
46 |
-
* @var string
|
47 |
-
*/
|
48 |
-
protected $type;
|
49 |
-
|
50 |
-
/**
|
51 |
-
* Time of the creation of this campaign, will be mapped to "__utmz" parameter.
|
52 |
-
*
|
53 |
-
* @see Internals\ParameterHolder::$__utmz
|
54 |
-
* @var DateTime
|
55 |
-
*/
|
56 |
-
protected $creationTime;
|
57 |
-
|
58 |
-
/**
|
59 |
-
* Response Count, will be mapped to "__utmz" parameter.
|
60 |
-
*
|
61 |
-
* Is also used to determine whether the campaign is new or repeated,
|
62 |
-
* which will be mapped to "utmcn" and "utmcr" parameters.
|
63 |
-
*
|
64 |
-
* @see Internals\ParameterHolder::$__utmz
|
65 |
-
* @see Internals\ParameterHolder::$utmcn
|
66 |
-
* @see Internals\ParameterHolder::$utmcr
|
67 |
-
* @var int
|
68 |
-
*/
|
69 |
-
protected $responseCount = 0;
|
70 |
-
|
71 |
-
/**
|
72 |
-
* Campaign ID, a.k.a. "utm_id" query parameter for ga.js
|
73 |
-
* Will be mapped to "__utmz" parameter.
|
74 |
-
*
|
75 |
-
* @see Internals\ParameterHolder::$__utmz
|
76 |
-
* @var int
|
77 |
-
*/
|
78 |
-
protected $id;
|
79 |
-
|
80 |
-
/**
|
81 |
-
* Source, a.k.a. "utm_source" query parameter for ga.js.
|
82 |
-
* Will be mapped to "utmcsr" key in "__utmz" parameter.
|
83 |
-
*
|
84 |
-
* @see Internals\ParameterHolder::$__utmz
|
85 |
-
* @var string
|
86 |
-
*/
|
87 |
-
protected $source;
|
88 |
-
|
89 |
-
/**
|
90 |
-
* Google AdWords Click ID, a.k.a. "gclid" query parameter for ga.js.
|
91 |
-
* Will be mapped to "utmgclid" key in "__utmz" parameter.
|
92 |
-
*
|
93 |
-
* @see Internals\ParameterHolder::$__utmz
|
94 |
-
* @var string
|
95 |
-
*/
|
96 |
-
protected $gClickId;
|
97 |
-
|
98 |
-
/**
|
99 |
-
* DoubleClick (?) Click ID. Will be mapped to "utmdclid" key in "__utmz" parameter.
|
100 |
-
*
|
101 |
-
* @see Internals\ParameterHolder::$__utmz
|
102 |
-
* @var string
|
103 |
-
*/
|
104 |
-
protected $dClickId;
|
105 |
-
|
106 |
-
/**
|
107 |
-
* Name, a.k.a. "utm_campaign" query parameter for ga.js.
|
108 |
-
* Will be mapped to "utmccn" key in "__utmz" parameter.
|
109 |
-
*
|
110 |
-
* @see Internals\ParameterHolder::$__utmz
|
111 |
-
* @var string
|
112 |
-
*/
|
113 |
-
protected $name;
|
114 |
-
|
115 |
-
/**
|
116 |
-
* Medium, a.k.a. "utm_medium" query parameter for ga.js.
|
117 |
-
* Will be mapped to "utmcmd" key in "__utmz" parameter.
|
118 |
-
*
|
119 |
-
* @see Internals\ParameterHolder::$__utmz
|
120 |
-
* @var string
|
121 |
-
*/
|
122 |
-
protected $medium;
|
123 |
-
|
124 |
-
/**
|
125 |
-
* Terms/Keywords, a.k.a. "utm_term" query parameter for ga.js.
|
126 |
-
* Will be mapped to "utmctr" key in "__utmz" parameter.
|
127 |
-
*
|
128 |
-
* @see Internals\ParameterHolder::$__utmz
|
129 |
-
* @var string
|
130 |
-
*/
|
131 |
-
protected $term;
|
132 |
-
|
133 |
-
/**
|
134 |
-
* Ad Content Description, a.k.a. "utm_content" query parameter for ga.js.
|
135 |
-
* Will be mapped to "utmcct" key in "__utmz" parameter.
|
136 |
-
*
|
137 |
-
* @see Internals\ParameterHolder::$__utmz
|
138 |
-
* @var string
|
139 |
-
*/
|
140 |
-
protected $content;
|
141 |
-
|
142 |
-
|
143 |
-
/**
|
144 |
-
* @const string
|
145 |
-
*/
|
146 |
-
const TYPE_DIRECT = 'direct';
|
147 |
-
/**
|
148 |
-
* @const string
|
149 |
-
*/
|
150 |
-
const TYPE_ORGANIC = 'organic';
|
151 |
-
/**
|
152 |
-
* @const string
|
153 |
-
*/
|
154 |
-
const TYPE_REFERRAL = 'referral';
|
155 |
-
|
156 |
-
|
157 |
-
/**
|
158 |
-
* @see createFromReferrer
|
159 |
-
* @param string $type See TYPE_* constants
|
160 |
-
*/
|
161 |
-
public function __construct($type) {
|
162 |
-
if(!in_array($type, array(self::TYPE_DIRECT, self::TYPE_ORGANIC, self::TYPE_REFERRAL))) {
|
163 |
-
Tracker::_raiseError('Campaign type has to be one of the Campaign::TYPE_* constant values.', __METHOD__);
|
164 |
-
}
|
165 |
-
|
166 |
-
$this->type = $type;
|
167 |
-
|
168 |
-
switch($type) {
|
169 |
-
// See http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/campaign/CampaignManager.as#375
|
170 |
-
case self::TYPE_DIRECT:
|
171 |
-
$this->name = '(direct)';
|
172 |
-
$this->source = '(direct)';
|
173 |
-
$this->medium = '(none)';
|
174 |
-
break;
|
175 |
-
// See http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/campaign/CampaignManager.as#340
|
176 |
-
case self::TYPE_REFERRAL:
|
177 |
-
$this->name = '(referral)';
|
178 |
-
$this->medium = 'referral';
|
179 |
-
break;
|
180 |
-
// See http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/campaign/CampaignManager.as#280
|
181 |
-
case self::TYPE_ORGANIC:
|
182 |
-
$this->name = '(organic)';
|
183 |
-
$this->medium = 'organic';
|
184 |
-
break;
|
185 |
-
}
|
186 |
-
|
187 |
-
$this->creationTime = new DateTime();
|
188 |
-
}
|
189 |
-
|
190 |
-
/**
|
191 |
-
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/campaign/CampaignManager.as#333
|
192 |
-
* @param string $url
|
193 |
-
* @return \UnitedPrototype\GoogleAnalytics\Campaign
|
194 |
-
*/
|
195 |
-
public static function createFromReferrer($url) {
|
196 |
-
$instance = new static(self::TYPE_REFERRAL);
|
197 |
-
$urlInfo = parse_url($url);
|
198 |
-
$instance->source = $urlInfo['host'];
|
199 |
-
$instance->content = $urlInfo['path'];
|
200 |
-
|
201 |
-
return $instance;
|
202 |
-
}
|
203 |
-
|
204 |
-
/**
|
205 |
-
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/campaign/CampaignTracker.as#153
|
206 |
-
*/
|
207 |
-
public function validate() {
|
208 |
-
// NOTE: gaforflash states that id and gClickId must also be specified,
|
209 |
-
// but that doesn't seem to be correct
|
210 |
-
if(!$this->source) {
|
211 |
-
Tracker::_raiseError('Campaigns need to have at least the "source" attribute defined.', __METHOD__);
|
212 |
-
}
|
213 |
-
}
|
214 |
-
|
215 |
-
/**
|
216 |
-
* @param string $type
|
217 |
-
*/
|
218 |
-
public function setType($type) {
|
219 |
-
$this->type = $type;
|
220 |
-
}
|
221 |
-
|
222 |
-
/**
|
223 |
-
* @return string
|
224 |
-
*/
|
225 |
-
public function getType() {
|
226 |
-
return $this->type;
|
227 |
-
}
|
228 |
-
|
229 |
-
/**
|
230 |
-
* @param DateTime $creationTime
|
231 |
-
*/
|
232 |
-
public function setCreationTime(DateTime $creationTime) {
|
233 |
-
$this->creationTime = $creationTime;
|
234 |
-
}
|
235 |
-
|
236 |
-
/**
|
237 |
-
* @return DateTime
|
238 |
-
*/
|
239 |
-
public function getCreationTime() {
|
240 |
-
return $this->creationTime;
|
241 |
-
}
|
242 |
-
|
243 |
-
/**
|
244 |
-
* @param int $esponseCount
|
245 |
-
*/
|
246 |
-
public function setResponseCount($responseCount) {
|
247 |
-
$this->responseCount = (int)$responseCount;
|
248 |
-
}
|
249 |
-
|
250 |
-
/**
|
251 |
-
* @return int
|
252 |
-
*/
|
253 |
-
public function getResponseCount() {
|
254 |
-
return $this->responseCount;
|
255 |
-
}
|
256 |
-
|
257 |
-
/**
|
258 |
-
* @param int $byAmount
|
259 |
-
*/
|
260 |
-
public function increaseResponseCount($byAmount = 1) {
|
261 |
-
$this->responseCount += $byAmount;
|
262 |
-
}
|
263 |
-
|
264 |
-
/**
|
265 |
-
* @param int $id
|
266 |
-
*/
|
267 |
-
public function setId($id) {
|
268 |
-
$this->id = $id;
|
269 |
-
}
|
270 |
-
|
271 |
-
/**
|
272 |
-
* @return int
|
273 |
-
*/
|
274 |
-
public function getId() {
|
275 |
-
return $this->id;
|
276 |
-
}
|
277 |
-
|
278 |
-
/**
|
279 |
-
* @param string $source
|
280 |
-
*/
|
281 |
-
public function setSource($source) {
|
282 |
-
$this->source = $source;
|
283 |
-
}
|
284 |
-
|
285 |
-
/**
|
286 |
-
* @return string
|
287 |
-
*/
|
288 |
-
public function getSource() {
|
289 |
-
return $this->source;
|
290 |
-
}
|
291 |
-
|
292 |
-
/**
|
293 |
-
* @param string $gClickId
|
294 |
-
*/
|
295 |
-
public function setGClickId($gClickId) {
|
296 |
-
$this->gClickId = $gClickId;
|
297 |
-
}
|
298 |
-
|
299 |
-
/**
|
300 |
-
* @return string
|
301 |
-
*/
|
302 |
-
public function getGClickId() {
|
303 |
-
return $this->gClickId;
|
304 |
-
}
|
305 |
-
|
306 |
-
/**
|
307 |
-
* @param string $dClickId
|
308 |
-
*/
|
309 |
-
public function setDClickId($dClickId) {
|
310 |
-
$this->dClickId = $dClickId;
|
311 |
-
}
|
312 |
-
|
313 |
-
/**
|
314 |
-
* @return string
|
315 |
-
*/
|
316 |
-
public function getDClickId() {
|
317 |
-
return $this->dClickId;
|
318 |
-
}
|
319 |
-
|
320 |
-
/**
|
321 |
-
* @param string $name
|
322 |
-
*/
|
323 |
-
public function setName($name) {
|
324 |
-
$this->name = $name;
|
325 |
-
}
|
326 |
-
|
327 |
-
/**
|
328 |
-
* @return string
|
329 |
-
*/
|
330 |
-
public function getName() {
|
331 |
-
return $this->name;
|
332 |
-
}
|
333 |
-
|
334 |
-
/**
|
335 |
-
* @param string $medium
|
336 |
-
*/
|
337 |
-
public function setMedium($medium) {
|
338 |
-
$this->medium = $medium;
|
339 |
-
}
|
340 |
-
|
341 |
-
/**
|
342 |
-
* @return string
|
343 |
-
*/
|
344 |
-
public function getMedium() {
|
345 |
-
return $this->medium;
|
346 |
-
}
|
347 |
-
|
348 |
-
/**
|
349 |
-
* @param string $term
|
350 |
-
*/
|
351 |
-
public function setTerm($term) {
|
352 |
-
$this->term = $term;
|
353 |
-
}
|
354 |
-
|
355 |
-
/**
|
356 |
-
* @return string
|
357 |
-
*/
|
358 |
-
public function getTerm() {
|
359 |
-
return $this->term;
|
360 |
-
}
|
361 |
-
|
362 |
-
/**
|
363 |
-
* @param string $content
|
364 |
-
*/
|
365 |
-
public function setContent($content) {
|
366 |
-
$this->content = $content;
|
367 |
-
}
|
368 |
-
|
369 |
-
/**
|
370 |
-
* @return string
|
371 |
-
*/
|
372 |
-
public function getContent() {
|
373 |
-
return $this->content;
|
374 |
-
}
|
375 |
-
|
376 |
-
}
|
377 |
-
|
378 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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/**
|
4 |
-
* Generic Server-Side Google Analytics PHP Client
|
5 |
-
*
|
6 |
-
* This library is free software; you can redistribute it and/or
|
7 |
-
* modify it under the terms of the GNU Lesser General Public
|
8 |
-
* License (LGPL) as published by the Free Software Foundation; either
|
9 |
-
* version 3 of the License, or (at your option) any later version.
|
10 |
-
*
|
11 |
-
* This library is distributed in the hope that it will be useful,
|
12 |
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
-
* Lesser General Public License for more details.
|
15 |
-
*
|
16 |
-
* You should have received a copy of the GNU Lesser General Public
|
17 |
-
* License along with this library; if not, write to the Free Software
|
18 |
-
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
19 |
-
*
|
20 |
-
* Google Analytics is a registered trademark of Google Inc.
|
21 |
-
*
|
22 |
-
* @link http://code.google.com/p/php-ga
|
23 |
-
*
|
24 |
-
* @license http://www.gnu.org/licenses/lgpl.html
|
25 |
-
* @author Thomas Bachem <tb@unitedprototype.com>
|
26 |
-
* @copyright Copyright (c) 2010 United Prototype GmbH (http://unitedprototype.com)
|
27 |
-
*/
|
28 |
-
|
29 |
-
namespace UnitedPrototype\GoogleAnalytics;
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Note: Doesn't necessarily have to be consistent across requests, as it doesn't
|
33 |
-
* alter the actual tracking result.
|
34 |
-
*
|
35 |
-
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/core/GIFRequest.as
|
36 |
-
*/
|
37 |
-
class Config {
|
38 |
-
|
39 |
-
/**
|
40 |
-
* How strict should errors get handled? After all, we do just do some
|
41 |
-
* tracking stuff here, and errors shouldn't break an application's
|
42 |
-
* functionality in production.
|
43 |
-
* RECOMMENDATION: Exceptions during deveopment, warnings in production.
|
44 |
-
*
|
45 |
-
* Assign any value of the self::ERROR_SEVERITY_* constants.
|
46 |
-
*
|
47 |
-
* @see Tracker::_raiseError()
|
48 |
-
* @var int
|
49 |
-
*/
|
50 |
-
protected $errorSeverity = self::ERROR_SEVERITY_EXCEPTIONS;
|
51 |
-
|
52 |
-
/**
|
53 |
-
* Ignore all errors completely.
|
54 |
-
*/
|
55 |
-
const ERROR_SEVERITY_SILENCE = 0;
|
56 |
-
/**
|
57 |
-
* Trigger PHP errors with a E_USER_WARNING error level.
|
58 |
-
*/
|
59 |
-
const ERROR_SEVERITY_WARNINGS = 1;
|
60 |
-
/**
|
61 |
-
* Throw UnitedPrototype\GoogleAnalytics\Exception exceptions.
|
62 |
-
*/
|
63 |
-
const ERROR_SEVERITY_EXCEPTIONS = 2;
|
64 |
-
|
65 |
-
/**
|
66 |
-
* Whether to just queue all requests on HttpRequest::fire() and actually send
|
67 |
-
* them on PHP script shutdown after all other tasks are done.
|
68 |
-
*
|
69 |
-
* This has two advantages:
|
70 |
-
* 1) It effectively doesn't affect app performance
|
71 |
-
* 2) It can e.g. handle custom variables that were set after scheduling a request
|
72 |
-
*
|
73 |
-
* @see Internals\Request\HttpRequest::fire()
|
74 |
-
* @var bool
|
75 |
-
*/
|
76 |
-
protected $sendOnShutdown = false;
|
77 |
-
|
78 |
-
/**
|
79 |
-
* Whether to make asynchronous requests to GA without waiting for any
|
80 |
-
* response (speeds up doing requests).
|
81 |
-
*
|
82 |
-
* @see Internals\Request\HttpRequest::send()
|
83 |
-
* @var bool
|
84 |
-
*/
|
85 |
-
protected $fireAndForget = false;
|
86 |
-
|
87 |
-
/**
|
88 |
-
* Logging callback, registered via setLoggingCallback(). Will be fired
|
89 |
-
* whenever a request gets sent out and receives the full HTTP request
|
90 |
-
* as the first and the full HTTP response (or null if the "fireAndForget"
|
91 |
-
* option or simulation mode are used) as the second argument.
|
92 |
-
*
|
93 |
-
* @var \Closure
|
94 |
-
*/
|
95 |
-
protected $loggingCallback;
|
96 |
-
|
97 |
-
/**
|
98 |
-
* Seconds (float allowed) to wait until timeout when connecting to the
|
99 |
-
* Google analytics endpoint host
|
100 |
-
*
|
101 |
-
* @see Internals\Request\HttpRequest::send()
|
102 |
-
* @var float
|
103 |
-
*/
|
104 |
-
protected $requestTimeout = 1;
|
105 |
-
|
106 |
-
// FIXME: Add SSL support, https://ssl.google-analytics.com
|
107 |
-
|
108 |
-
/**
|
109 |
-
* Google Analytics tracking request endpoint host. Can be set to null to
|
110 |
-
* silently simulate (and log) requests without actually sending them.
|
111 |
-
*
|
112 |
-
* @see Internals\Request\HttpRequest::send()
|
113 |
-
* @var string
|
114 |
-
*/
|
115 |
-
protected $endPointHost = 'www.google-analytics.com';
|
116 |
-
|
117 |
-
/**
|
118 |
-
* Google Analytics tracking request endpoint path
|
119 |
-
*
|
120 |
-
* @see Internals\Request\HttpRequest::send()
|
121 |
-
* @var string
|
122 |
-
*/
|
123 |
-
protected $endPointPath = '/__utm.gif';
|
124 |
-
|
125 |
-
/**
|
126 |
-
* Whether to anonymize IP addresses within Google Analytics by stripping
|
127 |
-
* the last IP address block, will be mapped to "aip" parameter
|
128 |
-
*
|
129 |
-
* @see Internals\ParameterHolder::$aip
|
130 |
-
* @link http://code.google.com/apis/analytics/docs/gaJS/gaJSApi_gat.html#_gat._anonymizeIp
|
131 |
-
* @var bool
|
132 |
-
*/
|
133 |
-
protected $anonymizeIpAddresses = false;
|
134 |
-
|
135 |
-
/**
|
136 |
-
* Defines a new sample set size (0-100) for Site Speed data collection.
|
137 |
-
* By default, a fixed 1% sampling of your site visitors make up the data pool from which
|
138 |
-
* the Site Speed metrics are derived.
|
139 |
-
*
|
140 |
-
* @see Page::$loadTime
|
141 |
-
* @link http://code.google.com/apis/analytics/docs/gaJS/gaJSApiBasicConfiguration.html#_gat.GA_Tracker_._setSiteSpeedSampleRate
|
142 |
-
* @var int
|
143 |
-
*/
|
144 |
-
protected $sitespeedSampleRate = 1;
|
145 |
-
|
146 |
-
|
147 |
-
/**
|
148 |
-
* @param array $properties
|
149 |
-
*/
|
150 |
-
public function __construct(array $properties = array()) {
|
151 |
-
foreach($properties as $property => $value) {
|
152 |
-
// PHP doesn't care about case in method names
|
153 |
-
$setterMethod = 'set' . $property;
|
154 |
-
|
155 |
-
if(method_exists($this, $setterMethod)) {
|
156 |
-
$this->$setterMethod($value);
|
157 |
-
} else {
|
158 |
-
return Tracker::_raiseError('There is no setting "' . $property . '".', __METHOD__);
|
159 |
-
}
|
160 |
-
}
|
161 |
-
}
|
162 |
-
|
163 |
-
/**
|
164 |
-
* @return int See self::ERROR_SEVERITY_* constants
|
165 |
-
*/
|
166 |
-
public function getErrorSeverity() {
|
167 |
-
return $this->errorSeverity;
|
168 |
-
}
|
169 |
-
|
170 |
-
/**
|
171 |
-
* @param int $errorSeverity See self::ERROR_SEVERITY_* constants
|
172 |
-
*/
|
173 |
-
public function setErrorSeverity($errorSeverity) {
|
174 |
-
$this->errorSeverity = $errorSeverity;
|
175 |
-
}
|
176 |
-
|
177 |
-
/**
|
178 |
-
* @return bool
|
179 |
-
*/
|
180 |
-
public function getSendOnShutdown() {
|
181 |
-
return $this->sendOnShutdown;
|
182 |
-
}
|
183 |
-
|
184 |
-
/**
|
185 |
-
* @param bool $sendOnShutdown
|
186 |
-
*/
|
187 |
-
public function setSendOnShutdown($sendOnShutdown) {
|
188 |
-
$this->sendOnShutdown = $sendOnShutdown;
|
189 |
-
}
|
190 |
-
|
191 |
-
/**
|
192 |
-
* @return bool
|
193 |
-
*/
|
194 |
-
public function getFireAndForget() {
|
195 |
-
return $this->fireAndForget;
|
196 |
-
}
|
197 |
-
|
198 |
-
/**
|
199 |
-
* @param bool $fireAndForget
|
200 |
-
*/
|
201 |
-
public function setFireAndForget($fireAndForget) {
|
202 |
-
$this->fireAndForget = (bool)$fireAndForget;
|
203 |
-
}
|
204 |
-
|
205 |
-
/**
|
206 |
-
* @return \Closure|null
|
207 |
-
*/
|
208 |
-
public function getLoggingCallback() {
|
209 |
-
return $this->loggingCallback;
|
210 |
-
}
|
211 |
-
|
212 |
-
/**
|
213 |
-
* @param \Closure $callback
|
214 |
-
*/
|
215 |
-
public function setLoggingCallback(\Closure $callback) {
|
216 |
-
$this->loggingCallback = $callback;
|
217 |
-
}
|
218 |
-
|
219 |
-
/**
|
220 |
-
* @return float
|
221 |
-
*/
|
222 |
-
public function getRequestTimeout() {
|
223 |
-
return $this->requestTimeout;
|
224 |
-
}
|
225 |
-
|
226 |
-
/**
|
227 |
-
* @param float $requestTimeout
|
228 |
-
*/
|
229 |
-
public function setRequestTimeout($requestTimeout) {
|
230 |
-
$this->requestTimeout = (float)$requestTimeout;
|
231 |
-
}
|
232 |
-
|
233 |
-
/**
|
234 |
-
* @return string|null
|
235 |
-
*/
|
236 |
-
public function getEndPointHost() {
|
237 |
-
return $this->endPointHost;
|
238 |
-
}
|
239 |
-
|
240 |
-
/**
|
241 |
-
* @param string|null $endPointHost
|
242 |
-
*/
|
243 |
-
public function setEndPointHost($endPointHost) {
|
244 |
-
$this->endPointHost = $endPointHost;
|
245 |
-
}
|
246 |
-
|
247 |
-
/**
|
248 |
-
* @return string
|
249 |
-
*/
|
250 |
-
public function getEndPointPath() {
|
251 |
-
return $this->endPointPath;
|
252 |
-
}
|
253 |
-
|
254 |
-
/**
|
255 |
-
* @param string $endPointPath
|
256 |
-
*/
|
257 |
-
public function setEndPointPath($endPointPath) {
|
258 |
-
$this->endPointPath = $endPointPath;
|
259 |
-
}
|
260 |
-
|
261 |
-
/**
|
262 |
-
* @return bool
|
263 |
-
*/
|
264 |
-
public function getAnonymizeIpAddresses() {
|
265 |
-
return $this->anonymizeIpAddresses;
|
266 |
-
}
|
267 |
-
|
268 |
-
/**
|
269 |
-
* @param bool $anonymizeIpAddresses
|
270 |
-
*/
|
271 |
-
public function setAnonymizeIpAddresses($anonymizeIpAddresses) {
|
272 |
-
$this->anonymizeIpAddresses = $anonymizeIpAddresses;
|
273 |
-
}
|
274 |
-
|
275 |
-
/**
|
276 |
-
* @return int
|
277 |
-
*/
|
278 |
-
public function getSitespeedSampleRate() {
|
279 |
-
return $this->sitespeedSampleRate;
|
280 |
-
}
|
281 |
-
|
282 |
-
/**
|
283 |
-
* @param int $sitespeedSampleRate
|
284 |
-
*/
|
285 |
-
public function setSitespeedSampleRate($sitespeedSampleRate) {
|
286 |
-
if((int)$sitespeedSampleRate != (float)$sitespeedSampleRate || $sitespeedSampleRate < 0 || $sitespeedSampleRate > 100) {
|
287 |
-
return Tracker::_raiseError('For consistency with ga.js, sample rates must be specified as a number between 0 and 100.', __METHOD__);
|
288 |
-
}
|
289 |
-
|
290 |
-
$this->sitespeedSampleRate = (int)$sitespeedSampleRate;
|
291 |
-
}
|
292 |
-
|
293 |
-
}
|
294 |
-
|
295 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Sluice/Connect/lib/GoogleAnalytics/CustomVariable.php
DELETED
@@ -1,180 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Generic Server-Side Google Analytics PHP Client
|
5 |
-
*
|
6 |
-
* This library is free software; you can redistribute it and/or
|
7 |
-
* modify it under the terms of the GNU Lesser General Public
|
8 |
-
* License (LGPL) as published by the Free Software Foundation; either
|
9 |
-
* version 3 of the License, or (at your option) any later version.
|
10 |
-
*
|
11 |
-
* This library is distributed in the hope that it will be useful,
|
12 |
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
-
* Lesser General Public License for more details.
|
15 |
-
*
|
16 |
-
* You should have received a copy of the GNU Lesser General Public
|
17 |
-
* License along with this library; if not, write to the Free Software
|
18 |
-
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
19 |
-
*
|
20 |
-
* Google Analytics is a registered trademark of Google Inc.
|
21 |
-
*
|
22 |
-
* @link http://code.google.com/p/php-ga
|
23 |
-
*
|
24 |
-
* @license http://www.gnu.org/licenses/lgpl.html
|
25 |
-
* @author Thomas Bachem <tb@unitedprototype.com>
|
26 |
-
* @copyright Copyright (c) 2010 United Prototype GmbH (http://unitedprototype.com)
|
27 |
-
*/
|
28 |
-
|
29 |
-
namespace UnitedPrototype\GoogleAnalytics;
|
30 |
-
|
31 |
-
use UnitedPrototype\GoogleAnalytics\Internals\Util;
|
32 |
-
|
33 |
-
/**
|
34 |
-
* @link http://code.google.com/apis/analytics/docs/tracking/gaTrackingCustomVariables.html
|
35 |
-
*/
|
36 |
-
class CustomVariable {
|
37 |
-
|
38 |
-
/**
|
39 |
-
* @var int
|
40 |
-
*/
|
41 |
-
protected $index;
|
42 |
-
|
43 |
-
/**
|
44 |
-
* WATCH OUT: It's a known issue that GA will not decode URL-encoded characters
|
45 |
-
* in custom variable names and values properly, so spaces will show up
|
46 |
-
* as "%20" in the interface etc.
|
47 |
-
*
|
48 |
-
* @link http://www.google.com/support/forum/p/Google%20Analytics/thread?tid=2cdb3ec0be32e078
|
49 |
-
* @var string
|
50 |
-
*/
|
51 |
-
protected $name;
|
52 |
-
|
53 |
-
/**
|
54 |
-
* WATCH OUT: It's a known issue that GA will not decode URL-encoded characters
|
55 |
-
* in custom variable names and values properly, so spaces will show up
|
56 |
-
* as "%20" in the interface etc.
|
57 |
-
*
|
58 |
-
* @link http://www.google.com/support/forum/p/Google%20Analytics/thread?tid=2cdb3ec0be32e078
|
59 |
-
* @var mixed
|
60 |
-
*/
|
61 |
-
protected $value;
|
62 |
-
|
63 |
-
/**
|
64 |
-
* See SCOPE_* constants
|
65 |
-
*
|
66 |
-
* @var int
|
67 |
-
*/
|
68 |
-
protected $scope = self::SCOPE_PAGE;
|
69 |
-
|
70 |
-
|
71 |
-
/**
|
72 |
-
* @const int
|
73 |
-
*/
|
74 |
-
const SCOPE_VISITOR = 1;
|
75 |
-
/**
|
76 |
-
* @const int
|
77 |
-
*/
|
78 |
-
const SCOPE_SESSION = 2;
|
79 |
-
/**
|
80 |
-
* @const int
|
81 |
-
*/
|
82 |
-
const SCOPE_PAGE = 3;
|
83 |
-
|
84 |
-
|
85 |
-
/**
|
86 |
-
* @param int $index
|
87 |
-
* @param string $name
|
88 |
-
* @param mixed $value
|
89 |
-
* @param int $scope See SCOPE_* constants
|
90 |
-
*/
|
91 |
-
public function __construct($index = null, $name = null, $value = null, $scope = null) {
|
92 |
-
if($index !== null) $this->setIndex($index);
|
93 |
-
if($name !== null) $this->setName($name);
|
94 |
-
if($value !== null) $this->setValue($value);
|
95 |
-
if($scope !== null) $this->setScope($scope);
|
96 |
-
}
|
97 |
-
|
98 |
-
public function validate() {
|
99 |
-
// According to the GA documentation, there is a limit to the combined size of
|
100 |
-
// name and value of 64 bytes after URL encoding,
|
101 |
-
// see http://code.google.com/apis/analytics/docs/tracking/gaTrackingCustomVariables.html#varTypes
|
102 |
-
// and http://xahlee.org/js/google_analytics_tracker_2010-07-01_expanded.js line 563
|
103 |
-
// This limit was increased to 128 bytes BEFORE encoding with the 2012-01 release of ga.js however,
|
104 |
-
// see http://code.google.com/apis/analytics/community/gajs_changelog.html
|
105 |
-
if(strlen($this->name . $this->value) > 128) {
|
106 |
-
Tracker::_raiseError('Custom Variable combined name and value length must not be larger than 128 bytes.', __METHOD__);
|
107 |
-
}
|
108 |
-
}
|
109 |
-
|
110 |
-
/**
|
111 |
-
* @return int
|
112 |
-
*/
|
113 |
-
public function getIndex() {
|
114 |
-
return $this->index;
|
115 |
-
}
|
116 |
-
|
117 |
-
/**
|
118 |
-
* @link http://code.google.com/intl/de-DE/apis/analytics/docs/tracking/gaTrackingCustomVariables.html#usage
|
119 |
-
* @param int $index
|
120 |
-
*/
|
121 |
-
public function setIndex($index) {
|
122 |
-
// Custom Variables are limited to five slots officially, but there seems to be a
|
123 |
-
// trick to allow for more of them which we could investigate at a later time (see
|
124 |
-
// http://analyticsimpact.com/2010/05/24/get-more-than-5-custom-variables-in-google-analytics/)
|
125 |
-
if($index < 1 || $index > 5) {
|
126 |
-
Tracker::_raiseError('Custom Variable index has to be between 1 and 5.', __METHOD__);
|
127 |
-
}
|
128 |
-
|
129 |
-
$this->index = (int)$index;
|
130 |
-
}
|
131 |
-
|
132 |
-
/**
|
133 |
-
* @return string
|
134 |
-
*/
|
135 |
-
public function getName() {
|
136 |
-
return $this->name;
|
137 |
-
}
|
138 |
-
|
139 |
-
/**
|
140 |
-
* @param string $name
|
141 |
-
*/
|
142 |
-
public function setName($name) {
|
143 |
-
$this->name = $name;
|
144 |
-
}
|
145 |
-
|
146 |
-
/**
|
147 |
-
* @return mixed
|
148 |
-
*/
|
149 |
-
public function getValue() {
|
150 |
-
return $this->value;
|
151 |
-
}
|
152 |
-
|
153 |
-
/**
|
154 |
-
* @param mixed $value
|
155 |
-
*/
|
156 |
-
public function setValue($value) {
|
157 |
-
$this->value = $value;
|
158 |
-
}
|
159 |
-
|
160 |
-
/**
|
161 |
-
* @return int
|
162 |
-
*/
|
163 |
-
public function getScope() {
|
164 |
-
return $this->scope;
|
165 |
-
}
|
166 |
-
|
167 |
-
/**
|
168 |
-
* @param int $scope
|
169 |
-
*/
|
170 |
-
public function setScope($scope) {
|
171 |
-
if(!in_array($scope, array(self::SCOPE_PAGE, self::SCOPE_SESSION, self::SCOPE_VISITOR))) {
|
172 |
-
Tracker::_raiseError('Custom Variable scope has to be one of the CustomVariable::SCOPE_* constant values.', __METHOD__);
|
173 |
-
}
|
174 |
-
|
175 |
-
$this->scope = (int)$scope;
|
176 |
-
}
|
177 |
-
|
178 |
-
}
|
179 |
-
|
180 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Sluice/Connect/lib/GoogleAnalytics/Event.php
DELETED
@@ -1,169 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Generic Server-Side Google Analytics PHP Client
|
5 |
-
*
|
6 |
-
* This library is free software; you can redistribute it and/or
|
7 |
-
* modify it under the terms of the GNU Lesser General Public
|
8 |
-
* License (LGPL) as published by the Free Software Foundation; either
|
9 |
-
* version 3 of the License, or (at your option) any later version.
|
10 |
-
*
|
11 |
-
* This library is distributed in the hope that it will be useful,
|
12 |
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
-
* Lesser General Public License for more details.
|
15 |
-
*
|
16 |
-
* You should have received a copy of the GNU Lesser General Public
|
17 |
-
* License along with this library; if not, write to the Free Software
|
18 |
-
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
19 |
-
*
|
20 |
-
* Google Analytics is a registered trademark of Google Inc.
|
21 |
-
*
|
22 |
-
* @link http://code.google.com/p/php-ga
|
23 |
-
*
|
24 |
-
* @license http://www.gnu.org/licenses/lgpl.html
|
25 |
-
* @author Thomas Bachem <tb@unitedprototype.com>
|
26 |
-
* @copyright Copyright (c) 2010 United Prototype GmbH (http://unitedprototype.com)
|
27 |
-
*/
|
28 |
-
|
29 |
-
namespace UnitedPrototype\GoogleAnalytics;
|
30 |
-
|
31 |
-
/**
|
32 |
-
* @link http://code.google.com/apis/analytics/docs/tracking/eventTrackerOverview.html
|
33 |
-
* @link http://code.google.com/apis/analytics/docs/gaJS/gaJSApiEventTracking.html
|
34 |
-
*/
|
35 |
-
class Event {
|
36 |
-
|
37 |
-
/**
|
38 |
-
* The general event category (e.g. "Videos").
|
39 |
-
*
|
40 |
-
* @var string
|
41 |
-
*/
|
42 |
-
protected $category;
|
43 |
-
|
44 |
-
/**
|
45 |
-
* The action for the event (e.g. "Play").
|
46 |
-
*
|
47 |
-
* @var string
|
48 |
-
*/
|
49 |
-
protected $action;
|
50 |
-
|
51 |
-
/**
|
52 |
-
* An optional descriptor for the event (e.g. the video's title).
|
53 |
-
*
|
54 |
-
* @var string
|
55 |
-
*/
|
56 |
-
protected $label;
|
57 |
-
|
58 |
-
/**
|
59 |
-
* An optional value associated with the event. You can see your event values in the Overview,
|
60 |
-
* Categories, and Actions reports, where they are listed by event or aggregated across events,
|
61 |
-
* depending upon your report view.
|
62 |
-
*
|
63 |
-
* @var int
|
64 |
-
*/
|
65 |
-
protected $value;
|
66 |
-
|
67 |
-
/**
|
68 |
-
* Default value is false. By default, event hits will impact a visitor's bounce rate.
|
69 |
-
* By setting this parameter to true, this event hit will not be used in bounce rate calculations.
|
70 |
-
*
|
71 |
-
* @var bool
|
72 |
-
*/
|
73 |
-
protected $noninteraction = false;
|
74 |
-
|
75 |
-
|
76 |
-
/**
|
77 |
-
* @param string $category
|
78 |
-
* @param string $action
|
79 |
-
* @param string $label
|
80 |
-
* @param int $value
|
81 |
-
* @param bool $noninteraction
|
82 |
-
*/
|
83 |
-
public function __construct($category = null, $action = null, $label = null, $value = null, $noninteraction = null) {
|
84 |
-
if($category !== null) $this->setCategory($category);
|
85 |
-
if($action !== null) $this->setAction($action);
|
86 |
-
if($label !== null) $this->setLabel($label);
|
87 |
-
if($value !== null) $this->setValue($value);
|
88 |
-
if($noninteraction !== null) $this->setNoninteraction($noninteraction);
|
89 |
-
}
|
90 |
-
|
91 |
-
public function validate() {
|
92 |
-
if($this->category === null || $this->action === null) {
|
93 |
-
Tracker::_raiseError('Events need at least to have a category and action defined.', __METHOD__);
|
94 |
-
}
|
95 |
-
}
|
96 |
-
|
97 |
-
/**
|
98 |
-
* @return string
|
99 |
-
*/
|
100 |
-
public function getCategory() {
|
101 |
-
return $this->category;
|
102 |
-
}
|
103 |
-
|
104 |
-
/**
|
105 |
-
* @param string $category
|
106 |
-
*/
|
107 |
-
public function setCategory($category) {
|
108 |
-
$this->category = $category;
|
109 |
-
}
|
110 |
-
|
111 |
-
/**
|
112 |
-
* @return string
|
113 |
-
*/
|
114 |
-
public function getAction() {
|
115 |
-
return $this->action;
|
116 |
-
}
|
117 |
-
|
118 |
-
/**
|
119 |
-
* @param string $action
|
120 |
-
*/
|
121 |
-
public function setAction($action) {
|
122 |
-
$this->action = $action;
|
123 |
-
}
|
124 |
-
|
125 |
-
/**
|
126 |
-
* @return string
|
127 |
-
*/
|
128 |
-
public function getLabel() {
|
129 |
-
return $this->label;
|
130 |
-
}
|
131 |
-
|
132 |
-
/**
|
133 |
-
* @param string $label
|
134 |
-
*/
|
135 |
-
public function setLabel($label) {
|
136 |
-
$this->label = $label;
|
137 |
-
}
|
138 |
-
|
139 |
-
/**
|
140 |
-
* @return int
|
141 |
-
*/
|
142 |
-
public function getValue() {
|
143 |
-
return $this->value;
|
144 |
-
}
|
145 |
-
|
146 |
-
/**
|
147 |
-
* @param int $value
|
148 |
-
*/
|
149 |
-
public function setValue($value) {
|
150 |
-
$this->value = (int)$value;
|
151 |
-
}
|
152 |
-
|
153 |
-
/**
|
154 |
-
* @return bool
|
155 |
-
*/
|
156 |
-
public function getNoninteraction() {
|
157 |
-
return $this->noninteraction;
|
158 |
-
}
|
159 |
-
|
160 |
-
/**
|
161 |
-
* @param bool $value
|
162 |
-
*/
|
163 |
-
public function setNoninteraction($value) {
|
164 |
-
$this->noninteraction = (bool)$value;
|
165 |
-
}
|
166 |
-
|
167 |
-
}
|
168 |
-
|
169 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Sluice/Connect/lib/GoogleAnalytics/Exception.php
DELETED
@@ -1,39 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Generic Server-Side Google Analytics PHP Client
|
5 |
-
*
|
6 |
-
* This library is free software; you can redistribute it and/or
|
7 |
-
* modify it under the terms of the GNU Lesser General Public
|
8 |
-
* License (LGPL) as published by the Free Software Foundation; either
|
9 |
-
* version 3 of the License, or (at your option) any later version.
|
10 |
-
*
|
11 |
-
* This library is distributed in the hope that it will be useful,
|
12 |
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
-
* Lesser General Public License for more details.
|
15 |
-
*
|
16 |
-
* You should have received a copy of the GNU Lesser General Public
|
17 |
-
* License along with this library; if not, write to the Free Software
|
18 |
-
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
19 |
-
*
|
20 |
-
* Google Analytics is a registered trademark of Google Inc.
|
21 |
-
*
|
22 |
-
* @link http://code.google.com/p/php-ga
|
23 |
-
*
|
24 |
-
* @license http://www.gnu.org/licenses/lgpl.html
|
25 |
-
* @author Thomas Bachem <tb@unitedprototype.com>
|
26 |
-
* @copyright Copyright (c) 2010 United Prototype GmbH (http://unitedprototype.com)
|
27 |
-
*/
|
28 |
-
|
29 |
-
namespace UnitedPrototype\GoogleAnalytics;
|
30 |
-
|
31 |
-
/**
|
32 |
-
* @see Config::$errorSeverity
|
33 |
-
* @see Tracker::_raiseError()
|
34 |
-
*/
|
35 |
-
class Exception extends \Exception {
|
36 |
-
|
37 |
-
}
|
38 |
-
|
39 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Sluice/Connect/lib/GoogleAnalytics/Internals/ParameterHolder.php
DELETED
@@ -1,536 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Generic Server-Side Google Analytics PHP Client
|
5 |
-
*
|
6 |
-
* This library is free software; you can redistribute it and/or
|
7 |
-
* modify it under the terms of the GNU Lesser General Public
|
8 |
-
* License (LGPL) as published by the Free Software Foundation; either
|
9 |
-
* version 3 of the License, or (at your option) any later version.
|
10 |
-
*
|
11 |
-
* This library is distributed in the hope that it will be useful,
|
12 |
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
-
* Lesser General Public License for more details.
|
15 |
-
*
|
16 |
-
* You should have received a copy of the GNU Lesser General Public
|
17 |
-
* License along with this library; if not, write to the Free Software
|
18 |
-
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
19 |
-
*
|
20 |
-
* Google Analytics is a registered trademark of Google Inc.
|
21 |
-
*
|
22 |
-
* @link http://code.google.com/p/php-ga
|
23 |
-
*
|
24 |
-
* @license http://www.gnu.org/licenses/lgpl.html
|
25 |
-
* @author Thomas Bachem <tb@unitedprototype.com>
|
26 |
-
* @copyright Copyright (c) 2010 United Prototype GmbH (http://unitedprototype.com)
|
27 |
-
*/
|
28 |
-
|
29 |
-
namespace UnitedPrototype\GoogleAnalytics\Internals;
|
30 |
-
|
31 |
-
use UnitedPrototype\GoogleAnalytics\Tracker;
|
32 |
-
|
33 |
-
/**
|
34 |
-
* This simple class is mainly meant to be a well-documented overview of all
|
35 |
-
* possible GA tracking parameters.
|
36 |
-
*
|
37 |
-
* @link http://code.google.com/apis/analytics/docs/tracking/gaTrackingTroubleshooting.html#gifParameters
|
38 |
-
*/
|
39 |
-
class ParameterHolder {
|
40 |
-
|
41 |
-
// - - - - - - - - - - - - - - - - - General parameters - - - - - - - - - - - - - - - - -
|
42 |
-
|
43 |
-
/**
|
44 |
-
* Google Analytics client version, e.g. "4.7.2"
|
45 |
-
* @var string
|
46 |
-
*/
|
47 |
-
public $utmwv = Tracker::VERSION;
|
48 |
-
|
49 |
-
/**
|
50 |
-
* Google Analytics account ID, e.g. "UA-1234567-8"
|
51 |
-
* @var string
|
52 |
-
*/
|
53 |
-
public $utmac;
|
54 |
-
|
55 |
-
/**
|
56 |
-
* Host Name, e.g. "www.example.com"
|
57 |
-
* @var string
|
58 |
-
*/
|
59 |
-
public $utmhn;
|
60 |
-
|
61 |
-
/**
|
62 |
-
* Indicates the type of request, which is one of null (for page), "event",
|
63 |
-
* "tran", "item", "social", "var" (deprecated) or "error" (used by ga.js
|
64 |
-
* for internal client error logging).
|
65 |
-
* @var string
|
66 |
-
*/
|
67 |
-
public $utmt;
|
68 |
-
|
69 |
-
/**
|
70 |
-
* Contains the amount of requests done in this session. Added in ga.js v4.9.2.
|
71 |
-
* @var int
|
72 |
-
*/
|
73 |
-
public $utms;
|
74 |
-
|
75 |
-
/**
|
76 |
-
* Unique ID (random number) generated for each GIF request
|
77 |
-
* @var int
|
78 |
-
*/
|
79 |
-
public $utmn;
|
80 |
-
|
81 |
-
/**
|
82 |
-
* Contains all cookie values, see below
|
83 |
-
* @var string
|
84 |
-
*/
|
85 |
-
public $utmcc;
|
86 |
-
|
87 |
-
/**
|
88 |
-
* Extensible Parameter, used for events and custom variables
|
89 |
-
* @var string
|
90 |
-
*/
|
91 |
-
public $utme;
|
92 |
-
|
93 |
-
/**
|
94 |
-
* Event "non-interaction" parameter. By default, the event hit will impact a visitor's bounce rate.
|
95 |
-
* By setting this parameter to 1, this event hit will not be used in bounce rate calculations.
|
96 |
-
* @link http://code.google.com/apis/analytics/docs/gaJS/gaJSApiEventTracking.html
|
97 |
-
* @var int
|
98 |
-
*/
|
99 |
-
public $utmni;
|
100 |
-
|
101 |
-
/**
|
102 |
-
* Whether to anonymize IP addresses within Google Analytics by stripping
|
103 |
-
* the last IP address block, either null or 1
|
104 |
-
* @var int
|
105 |
-
*/
|
106 |
-
public $aip;
|
107 |
-
|
108 |
-
/**
|
109 |
-
* Used for GA-internal statistical client function usage and error tracking,
|
110 |
-
* not implemented in php-ga as of now, but here for documentation completeness.
|
111 |
-
* @link http://glucik.blogspot.com/2011/02/utmu-google-analytics-request-parameter.html
|
112 |
-
* @var string
|
113 |
-
*/
|
114 |
-
public $utmu;
|
115 |
-
|
116 |
-
|
117 |
-
// - - - - - - - - - - - - - - - - - Page parameters - - - - - - - - - - - - - - - - -
|
118 |
-
|
119 |
-
/**
|
120 |
-
* Page request URI, e.g. "/path/page.html"
|
121 |
-
* @var string
|
122 |
-
*/
|
123 |
-
public $utmp;
|
124 |
-
|
125 |
-
/**
|
126 |
-
* Page title
|
127 |
-
* @var string
|
128 |
-
*/
|
129 |
-
public $utmdt;
|
130 |
-
|
131 |
-
/**
|
132 |
-
* Charset encoding (e.g. "UTF-8") or "-" as default
|
133 |
-
* @var string
|
134 |
-
*/
|
135 |
-
public $utmcs = '-';
|
136 |
-
|
137 |
-
/**
|
138 |
-
* Referer URL, e.g. "http://www.example.com/path/page.html", "-" as default
|
139 |
-
* or "0" for internal referers
|
140 |
-
* @var string
|
141 |
-
*/
|
142 |
-
public $utmr = '-';
|
143 |
-
|
144 |
-
|
145 |
-
// - - - - - - - - - - - - - - - - - Visitor parameters - - - - - - - - - - - - - - - - -
|
146 |
-
|
147 |
-
/**
|
148 |
-
* IP Address of the end user, e.g. "123.123.123.123", found in GA for Mobile examples,
|
149 |
-
* but sadly seems to be ignored in normal GA use
|
150 |
-
*
|
151 |
-
* @link http://github.com/mptre/php-ga/blob/master/ga.php
|
152 |
-
* @var string
|
153 |
-
*/
|
154 |
-
public $utmip;
|
155 |
-
|
156 |
-
/**
|
157 |
-
* Visitor's locale string (all lower-case, country part optional), e.g. "de-de"
|
158 |
-
* @var string
|
159 |
-
*/
|
160 |
-
public $utmul;
|
161 |
-
|
162 |
-
/**
|
163 |
-
* Visitor's Flash version, e.g. "9.0 r28" or "-" as default
|
164 |
-
* @var string
|
165 |
-
*/
|
166 |
-
public $utmfl = '-';
|
167 |
-
|
168 |
-
/**
|
169 |
-
* Visitor's Java support, either 0 or 1 or "-" as default
|
170 |
-
* @var int|string
|
171 |
-
*/
|
172 |
-
public $utmje = '-';
|
173 |
-
|
174 |
-
/**
|
175 |
-
* Visitor's screen color depth, e.g. "32-bit"
|
176 |
-
* @var string
|
177 |
-
*/
|
178 |
-
public $utmsc;
|
179 |
-
|
180 |
-
/**
|
181 |
-
* Visitor's screen resolution, e.g. "1024x768"
|
182 |
-
* @var string
|
183 |
-
*/
|
184 |
-
public $utmsr;
|
185 |
-
|
186 |
-
/**
|
187 |
-
* Visitor tracking cookie parameter.
|
188 |
-
*
|
189 |
-
* This cookie is typically written to the browser upon the first visit to your site from that web browser.
|
190 |
-
* If the cookie has been deleted by the browser operator, and the browser subsequently visits your site,
|
191 |
-
* a new __utma cookie is written with a different unique ID.
|
192 |
-
*
|
193 |
-
* This cookie is used to determine unique visitors to your site and it is updated with each page view.
|
194 |
-
* Additionally, this cookie is provided with a unique ID that Google Analytics uses to ensure both the
|
195 |
-
* validity and accessibility of the cookie as an extra security measure.
|
196 |
-
*
|
197 |
-
* Expiration:
|
198 |
-
* 2 years from set/update.
|
199 |
-
*
|
200 |
-
* Format:
|
201 |
-
* __utma=<domainHash>.<uniqueId>.<firstTime>.<lastTime>.<currentTime>.<sessionCount>
|
202 |
-
*
|
203 |
-
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/data/UTMA.as
|
204 |
-
* @var int
|
205 |
-
*/
|
206 |
-
public $__utma;
|
207 |
-
|
208 |
-
|
209 |
-
// - - - - - - - - - - - - - - - - - Session parameters - - - - - - - - - - - - - - - - -
|
210 |
-
|
211 |
-
/**
|
212 |
-
* Hit id for revenue per page tracking for AdSense, a random per-session ID
|
213 |
-
*
|
214 |
-
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/core/DocumentInfo.as#117
|
215 |
-
* @var int
|
216 |
-
*/
|
217 |
-
public $utmhid;
|
218 |
-
|
219 |
-
/**
|
220 |
-
* Session timeout cookie parameter.
|
221 |
-
* Will never be sent with requests, but stays here for documentation completeness.
|
222 |
-
*
|
223 |
-
* This cookie is used to establish and continue a user session with your site.
|
224 |
-
* When a user views a page on your site, the Google Analytics code attempts to update this cookie.
|
225 |
-
* If it does not find the cookie, a new one is written and a new session is established.
|
226 |
-
*
|
227 |
-
* Each time a user visits a different page on your site, this cookie is updated to expire in 30 minutes,
|
228 |
-
* thus continuing a single session for as long as user activity continues within 30-minute intervals.
|
229 |
-
*
|
230 |
-
* This cookie expires when a user pauses on a page on your site for longer than 30 minutes.
|
231 |
-
* You can modify the default length of a user session with the setSessionTimeout() method.
|
232 |
-
*
|
233 |
-
* Expiration:
|
234 |
-
* 30 minutes from set/update.
|
235 |
-
*
|
236 |
-
* Format:
|
237 |
-
* __utmb=<domainHash>.<trackCount>.<token>.<lastTime>
|
238 |
-
*
|
239 |
-
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/data/UTMB.as
|
240 |
-
* @var string
|
241 |
-
*/
|
242 |
-
public $__utmb;
|
243 |
-
|
244 |
-
/**
|
245 |
-
* Session tracking cookie parameter.
|
246 |
-
* Will never be sent with requests, but stays here for documentation completeness.
|
247 |
-
*
|
248 |
-
* This cookie operates in conjunction with the __utmb cookie to determine whether or not
|
249 |
-
* to establish a new session for the user.
|
250 |
-
* In particular, this cookie is not provided with an expiration date,
|
251 |
-
* so it expires when the user exits the browser.
|
252 |
-
*
|
253 |
-
* Should a user visit your site, exit the browser and then return to your website within 30 minutes,
|
254 |
-
* the absence of the __utmc cookie indicates that a new session needs to be established,
|
255 |
-
* despite the fact that the __utmb cookie has not yet expired.
|
256 |
-
*
|
257 |
-
* Expiration:
|
258 |
-
* Not set.
|
259 |
-
*
|
260 |
-
* Format:
|
261 |
-
* __utmc=<domainHash>
|
262 |
-
*
|
263 |
-
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/data/UTMC.as
|
264 |
-
* @var string
|
265 |
-
*/
|
266 |
-
public $__utmc;
|
267 |
-
|
268 |
-
|
269 |
-
// - - - - - - - - - - - - - - - - - E-Commerce parameters - - - - - - - - - - - - - - - - -
|
270 |
-
|
271 |
-
/**
|
272 |
-
* Product Code. This is the sku code for a given product, e.g. "989898ajssi"
|
273 |
-
* @var string
|
274 |
-
*/
|
275 |
-
public $utmipc;
|
276 |
-
|
277 |
-
/**
|
278 |
-
* Product Name, e.g. "T-Shirt"
|
279 |
-
* @var string
|
280 |
-
*/
|
281 |
-
public $utmipn;
|
282 |
-
|
283 |
-
/**
|
284 |
-
* Unit Price. Value is set to numbers only, e.g. 19.95
|
285 |
-
* @var float
|
286 |
-
*/
|
287 |
-
public $utmipr;
|
288 |
-
|
289 |
-
/**
|
290 |
-
* Unit Quantity, e.g. 4
|
291 |
-
* @var int
|
292 |
-
*/
|
293 |
-
public $utmiqt;
|
294 |
-
|
295 |
-
/**
|
296 |
-
* Variations on an item, e.g. "white", "black", "green" etc.
|
297 |
-
* @var string
|
298 |
-
*/
|
299 |
-
public $utmiva;
|
300 |
-
|
301 |
-
/**
|
302 |
-
* Order ID, e.g. "a2343898"
|
303 |
-
* @var string
|
304 |
-
*/
|
305 |
-
public $utmtid;
|
306 |
-
|
307 |
-
/**
|
308 |
-
* Affiliation
|
309 |
-
* @var string
|
310 |
-
*/
|
311 |
-
public $utmtst;
|
312 |
-
|
313 |
-
/**
|
314 |
-
* Total Cost, e.g. 20.00
|
315 |
-
* @var float
|
316 |
-
*/
|
317 |
-
public $utmtto;
|
318 |
-
|
319 |
-
/**
|
320 |
-
* Tax Cost, e.g. 4.23
|
321 |
-
* @var float
|
322 |
-
*/
|
323 |
-
public $utmttx;
|
324 |
-
|
325 |
-
/**
|
326 |
-
* Shipping Cost, e.g. 3.95
|
327 |
-
* @var float
|
328 |
-
*/
|
329 |
-
public $utmtsp;
|
330 |
-
|
331 |
-
/**
|
332 |
-
* Billing City, e.g. "Cologne"
|
333 |
-
* @var string
|
334 |
-
*/
|
335 |
-
public $utmtci;
|
336 |
-
|
337 |
-
/**
|
338 |
-
* Billing Region, e.g. "North Rhine-Westphalia"
|
339 |
-
* @var string
|
340 |
-
*/
|
341 |
-
public $utmtrg;
|
342 |
-
|
343 |
-
/**
|
344 |
-
* Billing Country, e.g. "Germany"
|
345 |
-
* @var string
|
346 |
-
*/
|
347 |
-
public $utmtco;
|
348 |
-
|
349 |
-
|
350 |
-
// - - - - - - - - - - - - - - - - - Campaign parameters - - - - - - - - - - - - - - - - -
|
351 |
-
|
352 |
-
/**
|
353 |
-
* Starts a new campaign session. Either utmcn or utmcr is present on any given request,
|
354 |
-
* but never both at the same time. Changes the campaign tracking data; but does not start
|
355 |
-
* a new session. Either 1 or not set.
|
356 |
-
*
|
357 |
-
* Found in gaforflash but not in ga.js, so we do not use it, but it will stay here for
|
358 |
-
* documentation completeness.
|
359 |
-
*
|
360 |
-
* @deprecated
|
361 |
-
* @var int
|
362 |
-
*/
|
363 |
-
public $utmcn;
|
364 |
-
|
365 |
-
/**
|
366 |
-
* Indicates a repeat campaign visit. This is set when any subsequent clicks occur on the
|
367 |
-
* same link. Either utmcn or utmcr is present on any given request, but never both at the
|
368 |
-
* same time. Either 1 or not set.
|
369 |
-
*
|
370 |
-
* Found in gaforflash but not in ga.js, so we do not use it, but it will stay here for
|
371 |
-
* documentation completeness.
|
372 |
-
*
|
373 |
-
* @deprecated
|
374 |
-
* @var int
|
375 |
-
*/
|
376 |
-
public $utmcr;
|
377 |
-
|
378 |
-
/**
|
379 |
-
* Campaign ID, a.k.a. "utm_id" query parameter for ga.js
|
380 |
-
* @var string
|
381 |
-
*/
|
382 |
-
public $utmcid;
|
383 |
-
|
384 |
-
/**
|
385 |
-
* Source, a.k.a. "utm_source" query parameter for ga.js
|
386 |
-
* @var string
|
387 |
-
*/
|
388 |
-
public $utmcsr;
|
389 |
-
|
390 |
-
/**
|
391 |
-
* Google AdWords Click ID, a.k.a. "gclid" query parameter for ga.js
|
392 |
-
* @var string
|
393 |
-
*/
|
394 |
-
public $utmgclid;
|
395 |
-
|
396 |
-
/**
|
397 |
-
* Not known for sure, but expected to be a DoubleClick Ad Click ID.
|
398 |
-
* @var string
|
399 |
-
*/
|
400 |
-
public $utmdclid;
|
401 |
-
|
402 |
-
/**
|
403 |
-
* Name, a.k.a. "utm_campaign" query parameter for ga.js
|
404 |
-
* @var string
|
405 |
-
*/
|
406 |
-
public $utmccn;
|
407 |
-
|
408 |
-
/**
|
409 |
-
* Medium, a.k.a. "utm_medium" query parameter for ga.js
|
410 |
-
* @var string
|
411 |
-
*/
|
412 |
-
public $utmcmd;
|
413 |
-
|
414 |
-
/**
|
415 |
-
* Terms/Keywords, a.k.a. "utm_term" query parameter for ga.js
|
416 |
-
* @var string
|
417 |
-
*/
|
418 |
-
public $utmctr;
|
419 |
-
|
420 |
-
/**
|
421 |
-
* Ad Content Description, a.k.a. "utm_content" query parameter for ga.js
|
422 |
-
* @var string
|
423 |
-
*/
|
424 |
-
public $utmcct;
|
425 |
-
|
426 |
-
/**
|
427 |
-
* Unknown so far. Found in ga.js.
|
428 |
-
* @var int
|
429 |
-
*/
|
430 |
-
public $utmcvr;
|
431 |
-
|
432 |
-
/**
|
433 |
-
* Campaign tracking cookie parameter.
|
434 |
-
*
|
435 |
-
* This cookie stores the type of referral used by the visitor to reach your site,
|
436 |
-
* whether via a direct method, a referring link, a website search, or a campaign such as an ad or an email link.
|
437 |
-
*
|
438 |
-
* It is used to calculate search engine traffic, ad campaigns and page navigation within your own site.
|
439 |
-
* The cookie is updated with each page view to your site.
|
440 |
-
*
|
441 |
-
* Expiration:
|
442 |
-
* 6 months from set/update.
|
443 |
-
*
|
444 |
-
* Format:
|
445 |
-
* __utmz=<domainHash>.<campaignCreation>.<campaignSessions>.<responseCount>.<campaignTracking>
|
446 |
-
*
|
447 |
-
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/data/UTMZ.as
|
448 |
-
* @var string
|
449 |
-
*/
|
450 |
-
public $__utmz;
|
451 |
-
|
452 |
-
|
453 |
-
// - - - - - - - - - - - - - - - - - Social Tracking parameters - - - - - - - - - - - - - - - - -
|
454 |
-
|
455 |
-
/**
|
456 |
-
* The network on which the action occurs (e.g. Facebook, Twitter).
|
457 |
-
* @var string
|
458 |
-
*/
|
459 |
-
public $utmsn;
|
460 |
-
|
461 |
-
/**
|
462 |
-
* The type of action that happens (e.g. Like, Send, Tweet).
|
463 |
-
* @var string
|
464 |
-
*/
|
465 |
-
public $utmsa;
|
466 |
-
|
467 |
-
/**
|
468 |
-
* The page URL from which the action occurred.
|
469 |
-
* @var string
|
470 |
-
*/
|
471 |
-
public $utmsid;
|
472 |
-
|
473 |
-
|
474 |
-
// - - - - - - - - - - - - - - - - - Google Website Optimizer (GWO) parameters - - - - - - - - - - - - - - - - -
|
475 |
-
|
476 |
-
// TODO: Implementation needed
|
477 |
-
/**
|
478 |
-
* Website Optimizer cookie parameter.
|
479 |
-
*
|
480 |
-
* This cookie is used by Website Optimizer and only set when Website Optimizer is used in combination
|
481 |
-
* with GA. See the Google Website Optimizer Help Center for details.
|
482 |
-
*
|
483 |
-
* Expiration:
|
484 |
-
* 2 years from set/update.
|
485 |
-
*
|
486 |
-
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/data/UTMX.as
|
487 |
-
* @var string
|
488 |
-
*/
|
489 |
-
public $__utmx;
|
490 |
-
|
491 |
-
|
492 |
-
// - - - - - - - - - - - - - - - - - Custom Variables parameters (deprecated) - - - - - - - - - - - - - - - - -
|
493 |
-
|
494 |
-
// TODO: Implementation needed?
|
495 |
-
/**
|
496 |
-
* Deprecated custom variables cookie parameter.
|
497 |
-
*
|
498 |
-
* This cookie parameter is no longer relevant as of migration from setVar() to
|
499 |
-
* setCustomVar() and hence not supported by this library, but will stay here for
|
500 |
-
* documentation completeness.
|
501 |
-
*
|
502 |
-
* The __utmv cookie passes the information provided via the setVar() method,
|
503 |
-
* which you use to create a custom user segment.
|
504 |
-
*
|
505 |
-
* Expiration:
|
506 |
-
* 2 years from set/update.
|
507 |
-
*
|
508 |
-
* Format:
|
509 |
-
* __utmv=<domainHash>.<value>
|
510 |
-
*
|
511 |
-
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/data/UTMV.as
|
512 |
-
* @deprecated
|
513 |
-
* @var string
|
514 |
-
*/
|
515 |
-
public $__utmv;
|
516 |
-
|
517 |
-
|
518 |
-
/**
|
519 |
-
* Converts this parameter holder to a pure PHP array, filtering out all properties
|
520 |
-
* prefixed with an underscore ("_").
|
521 |
-
*
|
522 |
-
* @return array
|
523 |
-
*/
|
524 |
-
public function toArray() {
|
525 |
-
$array = array();
|
526 |
-
foreach($this as $property => $value) {
|
527 |
-
if($property[0] != '_') {
|
528 |
-
$array[$property] = $value;
|
529 |
-
}
|
530 |
-
}
|
531 |
-
return $array;
|
532 |
-
}
|
533 |
-
|
534 |
-
}
|
535 |
-
|
536 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Sluice/Connect/lib/GoogleAnalytics/Internals/Request/EventRequest.php
DELETED
@@ -1,109 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Generic Server-Side Google Analytics PHP Client
|
5 |
-
*
|
6 |
-
* This library is free software; you can redistribute it and/or
|
7 |
-
* modify it under the terms of the GNU Lesser General Public
|
8 |
-
* License (LGPL) as published by the Free Software Foundation; either
|
9 |
-
* version 3 of the License, or (at your option) any later version.
|
10 |
-
*
|
11 |
-
* This library is distributed in the hope that it will be useful,
|
12 |
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
-
* Lesser General Public License for more details.
|
15 |
-
*
|
16 |
-
* You should have received a copy of the GNU Lesser General Public
|
17 |
-
* License along with this library; if not, write to the Free Software
|
18 |
-
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
19 |
-
*
|
20 |
-
* Google Analytics is a registered trademark of Google Inc.
|
21 |
-
*
|
22 |
-
* @link http://code.google.com/p/php-ga
|
23 |
-
*
|
24 |
-
* @license http://www.gnu.org/licenses/lgpl.html
|
25 |
-
* @author Thomas Bachem <tb@unitedprototype.com>
|
26 |
-
* @copyright Copyright (c) 2010 United Prototype GmbH (http://unitedprototype.com)
|
27 |
-
*/
|
28 |
-
|
29 |
-
namespace UnitedPrototype\GoogleAnalytics\Internals\Request;
|
30 |
-
|
31 |
-
use UnitedPrototype\GoogleAnalytics\Event;
|
32 |
-
|
33 |
-
use UnitedPrototype\GoogleAnalytics\Internals\X10;
|
34 |
-
|
35 |
-
class EventRequest extends Request {
|
36 |
-
|
37 |
-
/**
|
38 |
-
* @var \UnitedPrototype\GoogleAnalytics\Event
|
39 |
-
*/
|
40 |
-
protected $event;
|
41 |
-
|
42 |
-
|
43 |
-
/**
|
44 |
-
* @const int
|
45 |
-
*/
|
46 |
-
const X10_EVENT_PROJECT_ID = 5;
|
47 |
-
|
48 |
-
|
49 |
-
/**
|
50 |
-
* @return string
|
51 |
-
*/
|
52 |
-
protected function getType() {
|
53 |
-
return Request::TYPE_EVENT;
|
54 |
-
}
|
55 |
-
|
56 |
-
/**
|
57 |
-
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/v4/Tracker.as#1503
|
58 |
-
*
|
59 |
-
* @return \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder
|
60 |
-
*/
|
61 |
-
protected function buildParameters() {
|
62 |
-
$p = parent::buildParameters();
|
63 |
-
|
64 |
-
$x10 = new X10();
|
65 |
-
|
66 |
-
$x10->clearKey(self::X10_EVENT_PROJECT_ID);
|
67 |
-
$x10->clearValue(self::X10_EVENT_PROJECT_ID);
|
68 |
-
|
69 |
-
// Object / Category
|
70 |
-
$x10->setKey(self::X10_EVENT_PROJECT_ID, X10::OBJECT_KEY_NUM, $this->event->getCategory());
|
71 |
-
|
72 |
-
// Event Type / Action
|
73 |
-
$x10->setKey(self::X10_EVENT_PROJECT_ID, X10::TYPE_KEY_NUM, $this->event->getAction());
|
74 |
-
|
75 |
-
if($this->event->getLabel() !== null) {
|
76 |
-
// Event Description / Label
|
77 |
-
$x10->setKey(self::X10_EVENT_PROJECT_ID, X10::LABEL_KEY_NUM, $this->event->getLabel());
|
78 |
-
}
|
79 |
-
|
80 |
-
if($this->event->getValue() !== null) {
|
81 |
-
$x10->setValue(self::X10_EVENT_PROJECT_ID, X10::VALUE_VALUE_NUM, $this->event->getValue());
|
82 |
-
}
|
83 |
-
|
84 |
-
$p->utme .= $x10->renderUrlString();
|
85 |
-
|
86 |
-
if($this->event->getNoninteraction()) {
|
87 |
-
$p->utmni = 1;
|
88 |
-
}
|
89 |
-
|
90 |
-
return $p;
|
91 |
-
}
|
92 |
-
|
93 |
-
/**
|
94 |
-
* @return \UnitedPrototype\GoogleAnalytics\Event
|
95 |
-
*/
|
96 |
-
public function getEvent() {
|
97 |
-
return $this->event;
|
98 |
-
}
|
99 |
-
|
100 |
-
/**
|
101 |
-
* @param \UnitedPrototype\GoogleAnalytics\Event $event
|
102 |
-
*/
|
103 |
-
public function setEvent(Event $event) {
|
104 |
-
$this->event = $event;
|
105 |
-
}
|
106 |
-
|
107 |
-
}
|
108 |
-
|
109 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Sluice/Connect/lib/GoogleAnalytics/Internals/Request/HttpRequest.php
DELETED
@@ -1,239 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Generic Server-Side Google Analytics PHP Client
|
5 |
-
*
|
6 |
-
* This library is free software; you can redistribute it and/or
|
7 |
-
* modify it under the terms of the GNU Lesser General Public
|
8 |
-
* License (LGPL) as published by the Free Software Foundation; either
|
9 |
-
* version 3 of the License, or (at your option) any later version.
|
10 |
-
*
|
11 |
-
* This library is distributed in the hope that it will be useful,
|
12 |
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
-
* Lesser General Public License for more details.
|
15 |
-
*
|
16 |
-
* You should have received a copy of the GNU Lesser General Public
|
17 |
-
* License along with this library; if not, write to the Free Software
|
18 |
-
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
19 |
-
*
|
20 |
-
* Google Analytics is a registered trademark of Google Inc.
|
21 |
-
*
|
22 |
-
* @link http://code.google.com/p/php-ga
|
23 |
-
*
|
24 |
-
* @license http://www.gnu.org/licenses/lgpl.html
|
25 |
-
* @author Thomas Bachem <tb@unitedprototype.com>
|
26 |
-
* @copyright Copyright (c) 2010 United Prototype GmbH (http://unitedprototype.com)
|
27 |
-
*/
|
28 |
-
|
29 |
-
namespace UnitedPrototype\GoogleAnalytics\Internals\Request;
|
30 |
-
|
31 |
-
use UnitedPrototype\GoogleAnalytics\Config;
|
32 |
-
|
33 |
-
use UnitedPrototype\GoogleAnalytics\Internals\Util;
|
34 |
-
|
35 |
-
/**
|
36 |
-
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/core/GIFRequest.as
|
37 |
-
*/
|
38 |
-
abstract class HttpRequest {
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Indicates the type of request, will be mapped to "utmt" parameter
|
42 |
-
*
|
43 |
-
* @see ParameterHolder::$utmt
|
44 |
-
* @var string
|
45 |
-
*/
|
46 |
-
protected $type;
|
47 |
-
|
48 |
-
/**
|
49 |
-
* @var \UnitedPrototype\GoogleAnalytics\Config
|
50 |
-
*/
|
51 |
-
protected $config;
|
52 |
-
|
53 |
-
/**
|
54 |
-
* @var string
|
55 |
-
*/
|
56 |
-
protected $xForwardedFor;
|
57 |
-
|
58 |
-
/**
|
59 |
-
* @var string
|
60 |
-
*/
|
61 |
-
protected $userAgent;
|
62 |
-
|
63 |
-
|
64 |
-
/**
|
65 |
-
* @param \UnitedPrototype\GoogleAnalytics\Config $config
|
66 |
-
*/
|
67 |
-
public function __construct(Config $config = null) {
|
68 |
-
$this->setConfig($config ? $config : new Config());
|
69 |
-
}
|
70 |
-
|
71 |
-
/**
|
72 |
-
* @return \UnitedPrototype\GoogleAnalytics\Config
|
73 |
-
*/
|
74 |
-
public function getConfig() {
|
75 |
-
return $this->config;
|
76 |
-
}
|
77 |
-
|
78 |
-
/**
|
79 |
-
* @param \UnitedPrototype\GoogleAnalytics\Config $config
|
80 |
-
*/
|
81 |
-
public function setConfig(Config $config) {
|
82 |
-
$this->config = $config;
|
83 |
-
}
|
84 |
-
|
85 |
-
/**
|
86 |
-
* @param string $value
|
87 |
-
*/
|
88 |
-
protected function setXForwardedFor($value) {
|
89 |
-
$this->xForwardedFor = $value;
|
90 |
-
}
|
91 |
-
|
92 |
-
/**
|
93 |
-
* @param string $value
|
94 |
-
*/
|
95 |
-
protected function setUserAgent($value) {
|
96 |
-
$this->userAgent = $value;
|
97 |
-
}
|
98 |
-
|
99 |
-
/**
|
100 |
-
* @return string
|
101 |
-
*/
|
102 |
-
protected function buildHttpRequest() {
|
103 |
-
$parameters = $this->buildParameters();
|
104 |
-
|
105 |
-
// This constant is supported as the 4th argument of http_build_query()
|
106 |
-
// from PHP 5.3.6 on and will tell it to use rawurlencode() instead of urlencode()
|
107 |
-
// internally, see http://code.google.com/p/php-ga/issues/detail?id=3
|
108 |
-
if(defined('PHP_QUERY_RFC3986')) {
|
109 |
-
// http_build_query() does automatically skip all array entries
|
110 |
-
// with null values, exactly what we want here
|
111 |
-
$queryString = http_build_query($parameters->toArray(), '', '&', PHP_QUERY_RFC3986);
|
112 |
-
} else {
|
113 |
-
// Manually replace "+"s with "%20" for backwards-compatibility
|
114 |
-
$queryString = str_replace('+', '%20', http_build_query($parameters->toArray(), '', '&'));
|
115 |
-
}
|
116 |
-
// Mimic Javascript's encodeURIComponent() encoding for the query
|
117 |
-
// string just to be sure we are 100% consistent with GA's Javascript client
|
118 |
-
$queryString = Util::convertToUriComponentEncoding($queryString);
|
119 |
-
|
120 |
-
// Recent versions of ga.js use HTTP POST requests if the query string is too long
|
121 |
-
$usePost = strlen($queryString) > 2036;
|
122 |
-
|
123 |
-
if(!$usePost) {
|
124 |
-
$r = 'GET ' . $this->config->getEndpointPath() . '?' . $queryString . ' HTTP/1.0' . "\r\n";
|
125 |
-
} else {
|
126 |
-
// FIXME: The "/p" shouldn't be hardcoded here, instead we need a GET and a POST endpoint...
|
127 |
-
$r = 'POST /p' . $this->config->getEndpointPath() . ' HTTP/1.0' . "\r\n";
|
128 |
-
}
|
129 |
-
$r .= 'Host: ' . $this->config->getEndpointHost() . "\r\n";
|
130 |
-
|
131 |
-
if($this->userAgent) {
|
132 |
-
$r .= 'User-Agent: ' . str_replace(array("\n", "\r"), '', $this->userAgent) . "\r\n";
|
133 |
-
}
|
134 |
-
|
135 |
-
if($this->xForwardedFor) {
|
136 |
-
// Sadly "X-Fowarded-For" is not supported by GA so far,
|
137 |
-
// see e.g. http://www.google.com/support/forum/p/Google+Analytics/thread?tid=017691c9e71d4b24,
|
138 |
-
// but we include it nonetheless for the pure sake of correctness (and hope)
|
139 |
-
$r .= 'X-Forwarded-For: ' . str_replace(array("\n", "\r"), '', $this->xForwardedFor) . "\r\n";
|
140 |
-
}
|
141 |
-
|
142 |
-
if($usePost) {
|
143 |
-
// Don't ask me why "text/plain", but ga.js says so :)
|
144 |
-
$r .= 'Content-Type: text/plain' . "\r\n";
|
145 |
-
$r .= 'Content-Length: ' . strlen($queryString) . "\r\n";
|
146 |
-
}
|
147 |
-
|
148 |
-
$r .= 'Connection: close' . "\r\n";
|
149 |
-
$r .= "\r\n\r\n";
|
150 |
-
|
151 |
-
if($usePost) {
|
152 |
-
$r .= $queryString;
|
153 |
-
}
|
154 |
-
|
155 |
-
return $r;
|
156 |
-
}
|
157 |
-
|
158 |
-
/**
|
159 |
-
* @return \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder
|
160 |
-
*/
|
161 |
-
protected abstract function buildParameters();
|
162 |
-
|
163 |
-
/**
|
164 |
-
* This method should only be called directly or indirectly by fire(), but must
|
165 |
-
* remain public as it can be called by a closure function.
|
166 |
-
*
|
167 |
-
* Sends either a normal HTTP request with response or an asynchronous request
|
168 |
-
* to Google Analytics without waiting for the response. Will always return
|
169 |
-
* null in the latter case, or false if any connection problems arise.
|
170 |
-
*
|
171 |
-
* @see HttpRequest::fire()
|
172 |
-
* @param string $request
|
173 |
-
* @return null|string|bool
|
174 |
-
*/
|
175 |
-
public function _send() {
|
176 |
-
$request = $this->buildHttpRequest();
|
177 |
-
$response = null;
|
178 |
-
|
179 |
-
// Do not actually send the request if endpoint host is set to null
|
180 |
-
if($this->config->getEndpointHost() !== null) {
|
181 |
-
$timeout = $this->config->getRequestTimeout();
|
182 |
-
|
183 |
-
$socket = fsockopen($this->config->getEndpointHost(), 80, $errno, $errstr, $timeout);
|
184 |
-
if(!$socket) return false;
|
185 |
-
|
186 |
-
if($this->config->getFireAndForget()) {
|
187 |
-
stream_set_blocking($socket, false);
|
188 |
-
}
|
189 |
-
|
190 |
-
$timeoutS = intval($timeout);
|
191 |
-
$timeoutUs = ($timeout - $timeoutS) * 100000;
|
192 |
-
stream_set_timeout($socket, $timeoutS, $timeoutUs);
|
193 |
-
|
194 |
-
// Ensure that the full request is sent (see http://code.google.com/p/php-ga/issues/detail?id=11)
|
195 |
-
$sentData = 0;
|
196 |
-
$toBeSentData = strlen($request);
|
197 |
-
while($sentData < $toBeSentData) {
|
198 |
-
$sentData += fwrite($socket, $request);
|
199 |
-
}
|
200 |
-
|
201 |
-
if(!$this->config->getFireAndForget()) {
|
202 |
-
while(!feof($socket)) {
|
203 |
-
$response .= fgets($socket, 512);
|
204 |
-
}
|
205 |
-
}
|
206 |
-
|
207 |
-
fclose($socket);
|
208 |
-
}
|
209 |
-
|
210 |
-
if($loggingCallback = $this->config->getLoggingCallback()) {
|
211 |
-
$loggingCallback($request, $response);
|
212 |
-
}
|
213 |
-
|
214 |
-
return $response;
|
215 |
-
}
|
216 |
-
|
217 |
-
/**
|
218 |
-
* Simply delegates to send() if config option "sendOnShutdown" is disabled
|
219 |
-
* or enqueues the request by registering a PHP shutdown function.
|
220 |
-
*/
|
221 |
-
public function fire() {
|
222 |
-
if($this->config->getSendOnShutdown()) {
|
223 |
-
// This dumb variable assignment is needed as PHP prohibits using
|
224 |
-
// $this in closure use statements
|
225 |
-
$instance = $this;
|
226 |
-
// We use a closure here to retain the current values/states of
|
227 |
-
// this instance and $request (as the use statement will copy them
|
228 |
-
// into its own scope)
|
229 |
-
register_shutdown_function(function() use($instance) {
|
230 |
-
$instance->_send();
|
231 |
-
});
|
232 |
-
} else {
|
233 |
-
$this->_send();
|
234 |
-
}
|
235 |
-
}
|
236 |
-
|
237 |
-
}
|
238 |
-
|
239 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Sluice/Connect/lib/GoogleAnalytics/Internals/Request/ItemRequest.php
DELETED
@@ -1,106 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Generic Server-Side Google Analytics PHP Client
|
5 |
-
*
|
6 |
-
* This library is free software; you can redistribute it and/or
|
7 |
-
* modify it under the terms of the GNU Lesser General Public
|
8 |
-
* License (LGPL) as published by the Free Software Foundation; either
|
9 |
-
* version 3 of the License, or (at your option) any later version.
|
10 |
-
*
|
11 |
-
* This library is distributed in the hope that it will be useful,
|
12 |
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
-
* Lesser General Public License for more details.
|
15 |
-
*
|
16 |
-
* You should have received a copy of the GNU Lesser General Public
|
17 |
-
* License along with this library; if not, write to the Free Software
|
18 |
-
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
19 |
-
*
|
20 |
-
* Google Analytics is a registered trademark of Google Inc.
|
21 |
-
*
|
22 |
-
* @link http://code.google.com/p/php-ga
|
23 |
-
*
|
24 |
-
* @license http://www.gnu.org/licenses/lgpl.html
|
25 |
-
* @author Thomas Bachem <tb@unitedprototype.com>
|
26 |
-
* @copyright Copyright (c) 2010 United Prototype GmbH (http://unitedprototype.com)
|
27 |
-
*/
|
28 |
-
|
29 |
-
namespace UnitedPrototype\GoogleAnalytics\Internals\Request;
|
30 |
-
|
31 |
-
use UnitedPrototype\GoogleAnalytics\Item;
|
32 |
-
|
33 |
-
use UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder;
|
34 |
-
|
35 |
-
class ItemRequest extends Request {
|
36 |
-
|
37 |
-
/**
|
38 |
-
* @var \UnitedPrototype\GoogleAnalytics\Item
|
39 |
-
*/
|
40 |
-
protected $item;
|
41 |
-
|
42 |
-
|
43 |
-
/**
|
44 |
-
* @return string
|
45 |
-
*/
|
46 |
-
protected function getType() {
|
47 |
-
return Request::TYPE_ITEM;
|
48 |
-
}
|
49 |
-
|
50 |
-
/**
|
51 |
-
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/ecommerce/Item.as#61
|
52 |
-
*
|
53 |
-
* @return \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder
|
54 |
-
*/
|
55 |
-
protected function buildParameters() {
|
56 |
-
$p = parent::buildParameters();
|
57 |
-
|
58 |
-
$p->utmtid = $this->item->getOrderId();
|
59 |
-
$p->utmipc = $this->item->getSku();
|
60 |
-
$p->utmipn = $this->item->getName();
|
61 |
-
$p->utmiva = $this->item->getVariation();
|
62 |
-
$p->utmipr = $this->item->getPrice();
|
63 |
-
$p->utmiqt = $this->item->getQuantity();
|
64 |
-
|
65 |
-
return $p;
|
66 |
-
}
|
67 |
-
|
68 |
-
/**
|
69 |
-
* The GA Javascript client doesn't send any visitor information for
|
70 |
-
* e-commerce requests, so we don't either.
|
71 |
-
*
|
72 |
-
* @param \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder $p
|
73 |
-
* @return \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder
|
74 |
-
*/
|
75 |
-
protected function buildVisitorParameters(ParameterHolder $p) {
|
76 |
-
return $p;
|
77 |
-
}
|
78 |
-
|
79 |
-
/**
|
80 |
-
* The GA Javascript client doesn't send any custom variables for
|
81 |
-
* e-commerce requests, so we don't either.
|
82 |
-
*
|
83 |
-
* @param \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder $p
|
84 |
-
* @return \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder
|
85 |
-
*/
|
86 |
-
protected function buildCustomVariablesParameter(ParameterHolder $p) {
|
87 |
-
return $p;
|
88 |
-
}
|
89 |
-
|
90 |
-
/**
|
91 |
-
* @return \UnitedPrototype\GoogleAnalytics\Item
|
92 |
-
*/
|
93 |
-
public function getItem() {
|
94 |
-
return $this->item;
|
95 |
-
}
|
96 |
-
|
97 |
-
/**
|
98 |
-
* @param \UnitedPrototype\GoogleAnalytics\Item $item
|
99 |
-
*/
|
100 |
-
public function setItem(Item $item) {
|
101 |
-
$this->item = $item;
|
102 |
-
}
|
103 |
-
|
104 |
-
}
|
105 |
-
|
106 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Sluice/Connect/lib/GoogleAnalytics/Internals/Request/PageviewRequest.php
DELETED
@@ -1,108 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Generic Server-Side Google Analytics PHP Client
|
5 |
-
*
|
6 |
-
* This library is free software; you can redistribute it and/or
|
7 |
-
* modify it under the terms of the GNU Lesser General Public
|
8 |
-
* License (LGPL) as published by the Free Software Foundation; either
|
9 |
-
* version 3 of the License, or (at your option) any later version.
|
10 |
-
*
|
11 |
-
* This library is distributed in the hope that it will be useful,
|
12 |
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
-
* Lesser General Public License for more details.
|
15 |
-
*
|
16 |
-
* You should have received a copy of the GNU Lesser General Public
|
17 |
-
* License along with this library; if not, write to the Free Software
|
18 |
-
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
19 |
-
*
|
20 |
-
* Google Analytics is a registered trademark of Google Inc.
|
21 |
-
*
|
22 |
-
* @link http://code.google.com/p/php-ga
|
23 |
-
*
|
24 |
-
* @license http://www.gnu.org/licenses/lgpl.html
|
25 |
-
* @author Thomas Bachem <tb@unitedprototype.com>
|
26 |
-
* @copyright Copyright (c) 2010 United Prototype GmbH (http://unitedprototype.com)
|
27 |
-
*/
|
28 |
-
|
29 |
-
namespace UnitedPrototype\GoogleAnalytics\Internals\Request;
|
30 |
-
|
31 |
-
use UnitedPrototype\GoogleAnalytics\Page;
|
32 |
-
|
33 |
-
use UnitedPrototype\GoogleAnalytics\Internals\X10;
|
34 |
-
|
35 |
-
class PageviewRequest extends Request {
|
36 |
-
|
37 |
-
/**
|
38 |
-
* @var \UnitedPrototype\GoogleAnalytics\Page
|
39 |
-
*/
|
40 |
-
protected $page;
|
41 |
-
|
42 |
-
|
43 |
-
/**
|
44 |
-
* @const int
|
45 |
-
*/
|
46 |
-
const X10_SITESPEED_PROJECT_ID = 14;
|
47 |
-
|
48 |
-
|
49 |
-
/**
|
50 |
-
* @return string
|
51 |
-
*/
|
52 |
-
protected function getType() {
|
53 |
-
return Request::TYPE_PAGE;
|
54 |
-
}
|
55 |
-
|
56 |
-
/**
|
57 |
-
* @return \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder
|
58 |
-
*/
|
59 |
-
protected function buildParameters() {
|
60 |
-
$p = parent::buildParameters();
|
61 |
-
|
62 |
-
$p->utmp = $this->page->getPath();
|
63 |
-
$p->utmdt = $this->page->getTitle();
|
64 |
-
if($this->page->getCharset() !== null) {
|
65 |
-
$p->utmcs = $this->page->getCharset();
|
66 |
-
}
|
67 |
-
if($this->page->getReferrer() !== null) {
|
68 |
-
$p->utmr = $this->page->getReferrer();
|
69 |
-
}
|
70 |
-
|
71 |
-
if($this->page->getLoadTime() !== null) {
|
72 |
-
// Sample sitespeed measurements
|
73 |
-
if($p->utmn % 100 < $this->config->getSitespeedSampleRate()) {
|
74 |
-
$x10 = new X10();
|
75 |
-
|
76 |
-
$x10->clearKey(self::X10_SITESPEED_PROJECT_ID);
|
77 |
-
$x10->clearValue(self::X10_SITESPEED_PROJECT_ID);
|
78 |
-
|
79 |
-
// Taken from ga.js code
|
80 |
-
$key = max(min(floor($this->page->getLoadTime() / 100), 5000), 0) * 100;
|
81 |
-
$x10->setKey(self::X10_SITESPEED_PROJECT_ID, X10::OBJECT_KEY_NUM, $key);
|
82 |
-
|
83 |
-
$x10->setValue(self::X10_SITESPEED_PROJECT_ID, X10::VALUE_VALUE_NUM, $this->page->getLoadTime());
|
84 |
-
|
85 |
-
$p->utme .= $x10->renderUrlString();
|
86 |
-
}
|
87 |
-
}
|
88 |
-
|
89 |
-
return $p;
|
90 |
-
}
|
91 |
-
|
92 |
-
/**
|
93 |
-
* @return \UnitedPrototype\GoogleAnalytics\Page
|
94 |
-
*/
|
95 |
-
public function getPage() {
|
96 |
-
return $this->page;
|
97 |
-
}
|
98 |
-
|
99 |
-
/**
|
100 |
-
* @param \UnitedPrototype\GoogleAnalytics\Page $page
|
101 |
-
*/
|
102 |
-
public function setPage(Page $page) {
|
103 |
-
$this->page = $page;
|
104 |
-
}
|
105 |
-
|
106 |
-
}
|
107 |
-
|
108 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Sluice/Connect/lib/GoogleAnalytics/Internals/Request/Request.php
DELETED
@@ -1,363 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Generic Server-Side Google Analytics PHP Client
|
5 |
-
*
|
6 |
-
* This library is free software; you can redistribute it and/or
|
7 |
-
* modify it under the terms of the GNU Lesser General Public
|
8 |
-
* License (LGPL) as published by the Free Software Foundation; either
|
9 |
-
* version 3 of the License, or (at your option) any later version.
|
10 |
-
*
|
11 |
-
* This library is distributed in the hope that it will be useful,
|
12 |
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
-
* Lesser General Public License for more details.
|
15 |
-
*
|
16 |
-
* You should have received a copy of the GNU Lesser General Public
|
17 |
-
* License along with this library; if not, write to the Free Software
|
18 |
-
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
19 |
-
*
|
20 |
-
* Google Analytics is a registered trademark of Google Inc.
|
21 |
-
*
|
22 |
-
* @link http://code.google.com/p/php-ga
|
23 |
-
*
|
24 |
-
* @license http://www.gnu.org/licenses/lgpl.html
|
25 |
-
* @author Thomas Bachem <tb@unitedprototype.com>
|
26 |
-
* @copyright Copyright (c) 2010 United Prototype GmbH (http://unitedprototype.com)
|
27 |
-
*/
|
28 |
-
|
29 |
-
namespace UnitedPrototype\GoogleAnalytics\Internals\Request;
|
30 |
-
|
31 |
-
use UnitedPrototype\GoogleAnalytics\Tracker;
|
32 |
-
use UnitedPrototype\GoogleAnalytics\Visitor;
|
33 |
-
use UnitedPrototype\GoogleAnalytics\Session;
|
34 |
-
use UnitedPrototype\GoogleAnalytics\CustomVariable;
|
35 |
-
|
36 |
-
use UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder;
|
37 |
-
use UnitedPrototype\GoogleAnalytics\Internals\Util;
|
38 |
-
use UnitedPrototype\GoogleAnalytics\Internals\X10;
|
39 |
-
|
40 |
-
abstract class Request extends HttpRequest {
|
41 |
-
|
42 |
-
/**
|
43 |
-
* @var \UnitedPrototype\GoogleAnalytics\Tracker
|
44 |
-
*/
|
45 |
-
protected $tracker;
|
46 |
-
|
47 |
-
/**
|
48 |
-
* @var \UnitedPrototype\GoogleAnalytics\Visitor
|
49 |
-
*/
|
50 |
-
protected $visitor;
|
51 |
-
|
52 |
-
/**
|
53 |
-
* @var \UnitedPrototype\GoogleAnalytics\Session
|
54 |
-
*/
|
55 |
-
protected $session;
|
56 |
-
|
57 |
-
|
58 |
-
/**
|
59 |
-
* @const string
|
60 |
-
*/
|
61 |
-
const TYPE_PAGE = null;
|
62 |
-
/**
|
63 |
-
* @const string
|
64 |
-
*/
|
65 |
-
const TYPE_EVENT = 'event';
|
66 |
-
/**
|
67 |
-
* @const string
|
68 |
-
*/
|
69 |
-
const TYPE_TRANSACTION = 'tran';
|
70 |
-
/**
|
71 |
-
* @const string
|
72 |
-
*/
|
73 |
-
const TYPE_ITEM = 'item';
|
74 |
-
/**
|
75 |
-
* @const string
|
76 |
-
*/
|
77 |
-
const TYPE_SOCIAL = 'social';
|
78 |
-
/**
|
79 |
-
* This type of request is deprecated in favor of encoding custom variables
|
80 |
-
* within the "utme" parameter, but we include it here for completeness
|
81 |
-
*
|
82 |
-
* @see ParameterHolder::$__utmv
|
83 |
-
* @link http://code.google.com/apis/analytics/docs/gaJS/gaJSApiBasicConfiguration.html#_gat.GA_Tracker_._setVar
|
84 |
-
* @deprecated
|
85 |
-
* @const string
|
86 |
-
*/
|
87 |
-
const TYPE_CUSTOMVARIABLE = 'var';
|
88 |
-
|
89 |
-
/**
|
90 |
-
* @const int
|
91 |
-
*/
|
92 |
-
const X10_CUSTOMVAR_NAME_PROJECT_ID = 8;
|
93 |
-
/**
|
94 |
-
* @const int
|
95 |
-
*/
|
96 |
-
const X10_CUSTOMVAR_VALUE_PROJECT_ID = 9;
|
97 |
-
/**
|
98 |
-
* @const int
|
99 |
-
*/
|
100 |
-
const X10_CUSTOMVAR_SCOPE_PROJECT_ID = 11;
|
101 |
-
|
102 |
-
/**
|
103 |
-
* @const string
|
104 |
-
*/
|
105 |
-
const CAMPAIGN_DELIMITER = '|';
|
106 |
-
|
107 |
-
|
108 |
-
/**
|
109 |
-
* Indicates the type of request, will be mapped to "utmt" parameter
|
110 |
-
*
|
111 |
-
* @see ParameterHolder::$utmt
|
112 |
-
* @return string See Request::TYPE_* constants
|
113 |
-
*/
|
114 |
-
protected abstract function getType();
|
115 |
-
|
116 |
-
/**
|
117 |
-
* @return string
|
118 |
-
*/
|
119 |
-
protected function buildHttpRequest() {
|
120 |
-
$this->setXForwardedFor($this->visitor->getIpAddress());
|
121 |
-
$this->setUserAgent($this->visitor->getUserAgent());
|
122 |
-
|
123 |
-
// Increment session track counter for each request
|
124 |
-
$this->session->increaseTrackCount();
|
125 |
-
|
126 |
-
// See http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/v4/Configuration.as?r=237#48
|
127 |
-
// and http://code.google.com/intl/de-DE/apis/analytics/docs/tracking/eventTrackerGuide.html#implementationConsiderations
|
128 |
-
if($this->session->getTrackCount() > 500) {
|
129 |
-
Tracker::_raiseError('Google Analytics does not guarantee to process more than 500 requests per session.', __METHOD__);
|
130 |
-
}
|
131 |
-
|
132 |
-
if($this->tracker->getCampaign()) {
|
133 |
-
$this->tracker->getCampaign()->increaseResponseCount();
|
134 |
-
}
|
135 |
-
|
136 |
-
return parent::buildHttpRequest();
|
137 |
-
}
|
138 |
-
|
139 |
-
/**
|
140 |
-
* @return \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder
|
141 |
-
*/
|
142 |
-
protected function buildParameters() {
|
143 |
-
$p = new ParameterHolder();
|
144 |
-
|
145 |
-
$p->utmac = $this->tracker->getAccountId();
|
146 |
-
$p->utmhn = $this->tracker->getDomainName();
|
147 |
-
|
148 |
-
$p->utmt = $this->getType();
|
149 |
-
$p->utmn = Util::generate32bitRandom();
|
150 |
-
|
151 |
-
// The "utmip" parameter is only relevant if a mobile analytics
|
152 |
-
// ID (MO-123456-7) was given,
|
153 |
-
// see http://code.google.com/p/php-ga/issues/detail?id=9
|
154 |
-
$p->utmip = $this->visitor->getIpAddress();
|
155 |
-
|
156 |
-
$p->aip = $this->tracker->getConfig()->getAnonymizeIpAddresses() ? 1 : null;
|
157 |
-
if($p->aip) {
|
158 |
-
// Anonymize last IP block
|
159 |
-
$p->utmip = substr($p->utmip, 0, strrpos($p->utmip, '.')) . '.0';
|
160 |
-
}
|
161 |
-
|
162 |
-
$p->utmhid = $this->session->getSessionId();
|
163 |
-
$p->utms = $this->session->getTrackCount();
|
164 |
-
|
165 |
-
$p = $this->buildVisitorParameters($p);
|
166 |
-
$p = $this->buildCustomVariablesParameter($p);
|
167 |
-
$p = $this->buildCampaignParameters($p);
|
168 |
-
$p = $this->buildCookieParameters($p);
|
169 |
-
|
170 |
-
return $p;
|
171 |
-
}
|
172 |
-
|
173 |
-
/**
|
174 |
-
* @param \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder $p
|
175 |
-
* @return \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder
|
176 |
-
*/
|
177 |
-
protected function buildVisitorParameters(ParameterHolder $p) {
|
178 |
-
// Ensure correct locale format, see https://developer.mozilla.org/en/navigator.language
|
179 |
-
$p->utmul = strtolower(str_replace('_', '-', $this->visitor->getLocale()));
|
180 |
-
|
181 |
-
if($this->visitor->getFlashVersion() !== null) {
|
182 |
-
$p->utmfl = $this->visitor->getFlashVersion();
|
183 |
-
}
|
184 |
-
if($this->visitor->getJavaEnabled() !== null) {
|
185 |
-
$p->utmje = $this->visitor->getJavaEnabled();
|
186 |
-
}
|
187 |
-
if($this->visitor->getScreenColorDepth() !== null) {
|
188 |
-
$p->utmsc = $this->visitor->getScreenColorDepth() . '-bit';
|
189 |
-
}
|
190 |
-
$p->utmsr = $this->visitor->getScreenResolution();
|
191 |
-
|
192 |
-
return $p;
|
193 |
-
}
|
194 |
-
|
195 |
-
/**
|
196 |
-
* @link http://xahlee.org/js/google_analytics_tracker_2010-07-01_expanded.js line 575
|
197 |
-
* @param \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder $p
|
198 |
-
* @return \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder
|
199 |
-
*/
|
200 |
-
protected function buildCustomVariablesParameter(ParameterHolder $p) {
|
201 |
-
$customVars = $this->tracker->getCustomVariables();
|
202 |
-
if($customVars) {
|
203 |
-
if(count($customVars) > 5) {
|
204 |
-
// See http://code.google.com/intl/de-DE/apis/analytics/docs/tracking/gaTrackingCustomVariables.html#usage
|
205 |
-
Tracker::_raiseError('The sum of all custom variables cannot exceed 5 in any given request.', __METHOD__);
|
206 |
-
}
|
207 |
-
|
208 |
-
$x10 = new X10();
|
209 |
-
|
210 |
-
$x10->clearKey(self::X10_CUSTOMVAR_NAME_PROJECT_ID);
|
211 |
-
$x10->clearKey(self::X10_CUSTOMVAR_VALUE_PROJECT_ID);
|
212 |
-
$x10->clearKey(self::X10_CUSTOMVAR_SCOPE_PROJECT_ID);
|
213 |
-
|
214 |
-
foreach($customVars as $customVar) {
|
215 |
-
// Name and value get encoded here,
|
216 |
-
// see http://xahlee.org/js/google_analytics_tracker_2010-07-01_expanded.js line 563
|
217 |
-
$name = Util::encodeUriComponent($customVar->getName());
|
218 |
-
$value = Util::encodeUriComponent($customVar->getValue());
|
219 |
-
|
220 |
-
$x10->setKey(self::X10_CUSTOMVAR_NAME_PROJECT_ID, $customVar->getIndex(), $name);
|
221 |
-
$x10->setKey(self::X10_CUSTOMVAR_VALUE_PROJECT_ID, $customVar->getIndex(), $value);
|
222 |
-
if($customVar->getScope() !== null && $customVar->getScope() != CustomVariable::SCOPE_PAGE) {
|
223 |
-
$x10->setKey(self::X10_CUSTOMVAR_SCOPE_PROJECT_ID, $customVar->getIndex(), $customVar->getScope());
|
224 |
-
}
|
225 |
-
}
|
226 |
-
|
227 |
-
$p->utme .= $x10->renderUrlString();
|
228 |
-
}
|
229 |
-
|
230 |
-
return $p;
|
231 |
-
}
|
232 |
-
|
233 |
-
/**
|
234 |
-
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/core/GIFRequest.as#123
|
235 |
-
* @param \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder $p
|
236 |
-
* @return \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder
|
237 |
-
*/
|
238 |
-
protected function buildCookieParameters(ParameterHolder $p) {
|
239 |
-
$domainHash = $this->generateDomainHash();
|
240 |
-
|
241 |
-
$p->__utma = $domainHash . '.';
|
242 |
-
$p->__utma .= $this->visitor->getUniqueId() . '.';
|
243 |
-
$p->__utma .= $this->visitor->getFirstVisitTime()->format('U') . '.';
|
244 |
-
$p->__utma .= $this->visitor->getPreviousVisitTime()->format('U') . '.';
|
245 |
-
$p->__utma .= $this->visitor->getCurrentVisitTime()->format('U') . '.';
|
246 |
-
$p->__utma .= $this->visitor->getVisitCount();
|
247 |
-
|
248 |
-
$p->__utmb = $domainHash . '.';
|
249 |
-
$p->__utmb .= $this->session->getTrackCount() . '.';
|
250 |
-
// FIXME: What does "token" mean? I only encountered a value of 10 in my tests.
|
251 |
-
$p->__utmb .= 10 . '.';
|
252 |
-
$p->__utmb .= $this->session->getStartTime()->format('U');
|
253 |
-
|
254 |
-
$p->__utmc = $domainHash;
|
255 |
-
|
256 |
-
$cookies = array();
|
257 |
-
$cookies[] = '__utma=' . $p->__utma . ';';
|
258 |
-
if($p->__utmz) {
|
259 |
-
$cookies[] = '__utmz=' . $p->__utmz . ';';
|
260 |
-
}
|
261 |
-
if($p->__utmv) {
|
262 |
-
$cookies[] = '__utmv=' . $p->__utmv . ';';
|
263 |
-
}
|
264 |
-
|
265 |
-
$p->utmcc = implode('+', $cookies);
|
266 |
-
|
267 |
-
return $p;
|
268 |
-
}
|
269 |
-
|
270 |
-
/**
|
271 |
-
* @param \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder $p
|
272 |
-
* @return \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder
|
273 |
-
*/
|
274 |
-
protected function buildCampaignParameters(ParameterHolder $p) {
|
275 |
-
$campaign = $this->tracker->getCampaign();
|
276 |
-
if($campaign) {
|
277 |
-
$p->__utmz = $this->generateDomainHash() . '.';
|
278 |
-
$p->__utmz .= $campaign->getCreationTime()->format('U') . '.';
|
279 |
-
$p->__utmz .= $this->visitor->getVisitCount() . '.';
|
280 |
-
$p->__utmz .= $campaign->getResponseCount() . '.';
|
281 |
-
|
282 |
-
// See http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/campaign/CampaignTracker.as#236
|
283 |
-
$data = array(
|
284 |
-
'utmcid' => $campaign->getId(),
|
285 |
-
'utmcsr' => $campaign->getSource(),
|
286 |
-
'utmgclid' => $campaign->getGClickId(),
|
287 |
-
'utmdclid' => $campaign->getDClickId(),
|
288 |
-
'utmccn' => $campaign->getName(),
|
289 |
-
'utmcmd' => $campaign->getMedium(),
|
290 |
-
'utmctr' => $campaign->getTerm(),
|
291 |
-
'utmcct' => $campaign->getContent(),
|
292 |
-
);
|
293 |
-
foreach($data as $key => $value) {
|
294 |
-
if($value !== null && $value !== '') {
|
295 |
-
// Only spaces and pluses get escaped in gaforflash and ga.js, so we do the same
|
296 |
-
$p->__utmz .= $key . '=' . str_replace(array('+', ' '), '%20', $value) . static::CAMPAIGN_DELIMITER;
|
297 |
-
}
|
298 |
-
}
|
299 |
-
$p->__utmz = rtrim($p->__utmz, static::CAMPAIGN_DELIMITER);
|
300 |
-
}
|
301 |
-
|
302 |
-
return $p;
|
303 |
-
}
|
304 |
-
|
305 |
-
/**
|
306 |
-
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/v4/Tracker.as#585
|
307 |
-
* @return string
|
308 |
-
*/
|
309 |
-
protected function generateDomainHash() {
|
310 |
-
$hash = 1;
|
311 |
-
|
312 |
-
if($this->tracker->getAllowHash()) {
|
313 |
-
$hash = Util::generateHash($this->tracker->getDomainName());
|
314 |
-
}
|
315 |
-
|
316 |
-
return $hash;
|
317 |
-
}
|
318 |
-
|
319 |
-
/**
|
320 |
-
* @return \UnitedPrototype\GoogleAnalytics\Tracker
|
321 |
-
*/
|
322 |
-
public function getTracker() {
|
323 |
-
return $this->tracker;
|
324 |
-
}
|
325 |
-
|
326 |
-
/**
|
327 |
-
* @param \UnitedPrototype\GoogleAnalytics\Tracker $tracker
|
328 |
-
*/
|
329 |
-
public function setTracker(Tracker $tracker) {
|
330 |
-
$this->tracker = $tracker;
|
331 |
-
}
|
332 |
-
|
333 |
-
/**
|
334 |
-
* @return \UnitedPrototype\GoogleAnalytics\Visitor
|
335 |
-
*/
|
336 |
-
public function getVisitor() {
|
337 |
-
return $this->visitor;
|
338 |
-
}
|
339 |
-
|
340 |
-
/**
|
341 |
-
* @param \UnitedPrototype\GoogleAnalytics\Visitor $visitor
|
342 |
-
*/
|
343 |
-
public function setVisitor(Visitor $visitor) {
|
344 |
-
$this->visitor = $visitor;
|
345 |
-
}
|
346 |
-
|
347 |
-
/**
|
348 |
-
* @return \UnitedPrototype\GoogleAnalytics\Session
|
349 |
-
*/
|
350 |
-
public function getSession() {
|
351 |
-
return $this->session;
|
352 |
-
}
|
353 |
-
|
354 |
-
/**
|
355 |
-
* @param \UnitedPrototype\GoogleAnalytics\Session $session
|
356 |
-
*/
|
357 |
-
public function setSession(Session $session) {
|
358 |
-
$this->session = $session;
|
359 |
-
}
|
360 |
-
|
361 |
-
}
|
362 |
-
|
363 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Sluice/Connect/lib/GoogleAnalytics/Internals/Request/SocialInteractionRequest.php
DELETED
@@ -1,82 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Generic Server-Side Google Analytics PHP Client
|
5 |
-
*
|
6 |
-
* This library is free software; you can redistribute it and/or
|
7 |
-
* modify it under the terms of the GNU Lesser General Public
|
8 |
-
* License (LGPL) as published by the Free Software Foundation; either
|
9 |
-
* version 3 of the License, or (at your option) any later version.
|
10 |
-
*
|
11 |
-
* This library is distributed in the hope that it will be useful,
|
12 |
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
-
* Lesser General Public License for more details.
|
15 |
-
*
|
16 |
-
* You should have received a copy of the GNU Lesser General Public
|
17 |
-
* License along with this library; if not, write to the Free Software
|
18 |
-
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
19 |
-
*
|
20 |
-
* Google Analytics is a registered trademark of Google Inc.
|
21 |
-
*
|
22 |
-
* @link http://code.google.com/p/php-ga
|
23 |
-
*
|
24 |
-
* @license http://www.gnu.org/licenses/lgpl.html
|
25 |
-
* @author Thomas Bachem <tb@unitedprototype.com>
|
26 |
-
* @copyright Copyright (c) 2010 United Prototype GmbH (http://unitedprototype.com)
|
27 |
-
*/
|
28 |
-
|
29 |
-
namespace UnitedPrototype\GoogleAnalytics\Internals\Request;
|
30 |
-
|
31 |
-
use UnitedPrototype\GoogleAnalytics\SocialInteraction;
|
32 |
-
|
33 |
-
class SocialinteractionRequest extends PageviewRequest {
|
34 |
-
|
35 |
-
/**
|
36 |
-
* @var \UnitedPrototype\GoogleAnalytics\SocialInteraction
|
37 |
-
*/
|
38 |
-
protected $socialInteraction;
|
39 |
-
|
40 |
-
|
41 |
-
/**
|
42 |
-
* @return string
|
43 |
-
*/
|
44 |
-
protected function getType() {
|
45 |
-
return Request::TYPE_SOCIAL;
|
46 |
-
}
|
47 |
-
|
48 |
-
/**
|
49 |
-
* @return \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder
|
50 |
-
*/
|
51 |
-
protected function buildParameters() {
|
52 |
-
$p = parent::buildParameters();
|
53 |
-
|
54 |
-
$p->utmsn = $this->socialInteraction->getNetwork();
|
55 |
-
$p->utmsa = $this->socialInteraction->getAction();
|
56 |
-
$p->utmsid = $this->socialInteraction->getTarget();
|
57 |
-
if($p->utmsid === null) {
|
58 |
-
// Default to page path like ga.js,
|
59 |
-
// see http://code.google.com/apis/analytics/docs/tracking/gaTrackingSocial.html#settingUp
|
60 |
-
$p->utmsid = $this->page->getPath();
|
61 |
-
}
|
62 |
-
|
63 |
-
return $p;
|
64 |
-
}
|
65 |
-
|
66 |
-
/**
|
67 |
-
* @return \UnitedPrototype\GoogleAnalytics\SocialInteraction
|
68 |
-
*/
|
69 |
-
public function getSocialInteraction() {
|
70 |
-
return $this->socialInteraction;
|
71 |
-
}
|
72 |
-
|
73 |
-
/**
|
74 |
-
* @param \UnitedPrototype\GoogleAnalytics\SocialInteraction $socialInteraction
|
75 |
-
*/
|
76 |
-
public function setSocialInteraction(SocialInteraction $socialInteraction) {
|
77 |
-
$this->socialInteraction = $socialInteraction;
|
78 |
-
}
|
79 |
-
|
80 |
-
}
|
81 |
-
|
82 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Sluice/Connect/lib/GoogleAnalytics/Internals/Request/TransactionRequest.php
DELETED
@@ -1,108 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Generic Server-Side Google Analytics PHP Client
|
5 |
-
*
|
6 |
-
* This library is free software; you can redistribute it and/or
|
7 |
-
* modify it under the terms of the GNU Lesser General Public
|
8 |
-
* License (LGPL) as published by the Free Software Foundation; either
|
9 |
-
* version 3 of the License, or (at your option) any later version.
|
10 |
-
*
|
11 |
-
* This library is distributed in the hope that it will be useful,
|
12 |
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
-
* Lesser General Public License for more details.
|
15 |
-
*
|
16 |
-
* You should have received a copy of the GNU Lesser General Public
|
17 |
-
* License along with this library; if not, write to the Free Software
|
18 |
-
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
19 |
-
*
|
20 |
-
* Google Analytics is a registered trademark of Google Inc.
|
21 |
-
*
|
22 |
-
* @link http://code.google.com/p/php-ga
|
23 |
-
*
|
24 |
-
* @license http://www.gnu.org/licenses/lgpl.html
|
25 |
-
* @author Thomas Bachem <tb@unitedprototype.com>
|
26 |
-
* @copyright Copyright (c) 2010 United Prototype GmbH (http://unitedprototype.com)
|
27 |
-
*/
|
28 |
-
|
29 |
-
namespace UnitedPrototype\GoogleAnalytics\Internals\Request;
|
30 |
-
|
31 |
-
use UnitedPrototype\GoogleAnalytics\Transaction;
|
32 |
-
|
33 |
-
use UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder;
|
34 |
-
|
35 |
-
class TransactionRequest extends Request {
|
36 |
-
|
37 |
-
/**
|
38 |
-
* @var \UnitedPrototype\GoogleAnalytics\Transaction
|
39 |
-
*/
|
40 |
-
protected $transaction;
|
41 |
-
|
42 |
-
|
43 |
-
/**
|
44 |
-
* @return string
|
45 |
-
*/
|
46 |
-
protected function getType() {
|
47 |
-
return Request::TYPE_TRANSACTION;
|
48 |
-
}
|
49 |
-
|
50 |
-
/**
|
51 |
-
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/ecommerce/Transaction.as#76
|
52 |
-
*
|
53 |
-
* @return \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder
|
54 |
-
*/
|
55 |
-
protected function buildParameters() {
|
56 |
-
$p = parent::buildParameters();
|
57 |
-
|
58 |
-
$p->utmtid = $this->transaction->getOrderId();
|
59 |
-
$p->utmtst = $this->transaction->getAffiliation();
|
60 |
-
$p->utmtto = $this->transaction->getTotal();
|
61 |
-
$p->utmttx = $this->transaction->getTax();
|
62 |
-
$p->utmtsp = $this->transaction->getShipping();
|
63 |
-
$p->utmtci = $this->transaction->getCity();
|
64 |
-
$p->utmtrg = $this->transaction->getRegion();
|
65 |
-
$p->utmtco = $this->transaction->getCountry();
|
66 |
-
|
67 |
-
return $p;
|
68 |
-
}
|
69 |
-
|
70 |
-
/**
|
71 |
-
* The GA Javascript client doesn't send any visitor information for
|
72 |
-
* e-commerce requests, so we don't either.
|
73 |
-
*
|
74 |
-
* @param \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder $p
|
75 |
-
* @return \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder
|
76 |
-
*/
|
77 |
-
protected function buildVisitorParameters(ParameterHolder $p) {
|
78 |
-
return $p;
|
79 |
-
}
|
80 |
-
|
81 |
-
/**
|
82 |
-
* The GA Javascript client doesn't send any custom variables for
|
83 |
-
* e-commerce requests, so we don't either.
|
84 |
-
*
|
85 |
-
* @param \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder $p
|
86 |
-
* @return \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder
|
87 |
-
*/
|
88 |
-
protected function buildCustomVariablesParameter(ParameterHolder $p) {
|
89 |
-
return $p;
|
90 |
-
}
|
91 |
-
|
92 |
-
/**
|
93 |
-
* @return \UnitedPrototype\GoogleAnalytics\Transaction
|
94 |
-
*/
|
95 |
-
public function getTransaction() {
|
96 |
-
return $this->transaction;
|
97 |
-
}
|
98 |
-
|
99 |
-
/**
|
100 |
-
* @param \UnitedPrototype\GoogleAnalytics\Transaction $transaction
|
101 |
-
*/
|
102 |
-
public function setTransaction(Transaction $transaction) {
|
103 |
-
$this->transaction = $transaction;
|
104 |
-
}
|
105 |
-
|
106 |
-
}
|
107 |
-
|
108 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Sluice/Connect/lib/GoogleAnalytics/Internals/Util.php
DELETED
@@ -1,105 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Generic Server-Side Google Analytics PHP Client
|
5 |
-
*
|
6 |
-
* This library is free software; you can redistribute it and/or
|
7 |
-
* modify it under the terms of the GNU Lesser General Public
|
8 |
-
* License (LGPL) as published by the Free Software Foundation; either
|
9 |
-
* version 3 of the License, or (at your option) any later version.
|
10 |
-
*
|
11 |
-
* This library is distributed in the hope that it will be useful,
|
12 |
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
-
* Lesser General Public License for more details.
|
15 |
-
*
|
16 |
-
* You should have received a copy of the GNU Lesser General Public
|
17 |
-
* License along with this library; if not, write to the Free Software
|
18 |
-
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
19 |
-
*
|
20 |
-
* Google Analytics is a registered trademark of Google Inc.
|
21 |
-
*
|
22 |
-
* @link http://code.google.com/p/php-ga
|
23 |
-
*
|
24 |
-
* @license http://www.gnu.org/licenses/lgpl.html
|
25 |
-
* @author Thomas Bachem <tb@unitedprototype.com>
|
26 |
-
* @copyright Copyright (c) 2010 United Prototype GmbH (http://unitedprototype.com)
|
27 |
-
*/
|
28 |
-
|
29 |
-
namespace UnitedPrototype\GoogleAnalytics\Internals;
|
30 |
-
|
31 |
-
/**
|
32 |
-
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/core/Utils.as
|
33 |
-
*/
|
34 |
-
class Util {
|
35 |
-
|
36 |
-
/**
|
37 |
-
* This class does only have public static methods, no instantiation necessary
|
38 |
-
*/
|
39 |
-
private function __construct() { }
|
40 |
-
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Mimics Javascript's encodeURIComponent() function for consistency with the GA Javascript client.
|
44 |
-
*
|
45 |
-
* @param mixed $value
|
46 |
-
* @return string
|
47 |
-
*/
|
48 |
-
public static function encodeUriComponent($value) {
|
49 |
-
return static::convertToUriComponentEncoding(rawurlencode($value));
|
50 |
-
}
|
51 |
-
|
52 |
-
/**
|
53 |
-
* Here as a separate method so it can also be applied to e.g. a http_build_query() result.
|
54 |
-
*
|
55 |
-
* @link http://stackoverflow.com/questions/1734250/what-is-the-equivalent-of-javascripts-encodeuricomponent-in-php/1734255#1734255
|
56 |
-
* @link http://devpro.it/examples/php_js_escaping.php
|
57 |
-
*
|
58 |
-
* @param string $encodedValue
|
59 |
-
* @return string
|
60 |
-
*/
|
61 |
-
public static function convertToUriComponentEncoding($encodedValue) {
|
62 |
-
return str_replace(array('%21', '%2A', '%27', '%28', '%29'), array('!', '*', "'", '(', ')'), $encodedValue);
|
63 |
-
}
|
64 |
-
|
65 |
-
/**
|
66 |
-
* Generates a 32bit random number.
|
67 |
-
*
|
68 |
-
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/core/Utils.as#33
|
69 |
-
* @return int
|
70 |
-
*/
|
71 |
-
public static function generate32bitRandom() {
|
72 |
-
return round((rand() / getrandmax()) * 0x7fffffff);
|
73 |
-
}
|
74 |
-
|
75 |
-
/**
|
76 |
-
* Generates a hash for input string.
|
77 |
-
*
|
78 |
-
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/core/Utils.as#44
|
79 |
-
* @param string $string
|
80 |
-
* @return int
|
81 |
-
*/
|
82 |
-
public static function generateHash($string) {
|
83 |
-
$string = (string)$string;
|
84 |
-
$hash = 1;
|
85 |
-
|
86 |
-
if($string !== null && $string !== '') {
|
87 |
-
$hash = 0;
|
88 |
-
|
89 |
-
$length = strlen($string);
|
90 |
-
for($pos = $length - 1; $pos >= 0; $pos--) {
|
91 |
-
$current = ord($string[$pos]);
|
92 |
-
$hash = (($hash << 6) & 0xfffffff) + $current + ($current << 14);
|
93 |
-
$leftMost7 = $hash & 0xfe00000;
|
94 |
-
if($leftMost7 != 0) {
|
95 |
-
$hash ^= $leftMost7 >> 21;
|
96 |
-
}
|
97 |
-
}
|
98 |
-
}
|
99 |
-
|
100 |
-
return $hash;
|
101 |
-
}
|
102 |
-
|
103 |
-
}
|
104 |
-
|
105 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Sluice/Connect/lib/GoogleAnalytics/Internals/X10.php
DELETED
@@ -1,331 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Generic Server-Side Google Analytics PHP Client
|
5 |
-
*
|
6 |
-
* This library is free software; you can redistribute it and/or
|
7 |
-
* modify it under the terms of the GNU Lesser General Public
|
8 |
-
* License (LGPL) as published by the Free Software Foundation; either
|
9 |
-
* version 3 of the License, or (at your option) any later version.
|
10 |
-
*
|
11 |
-
* This library is distributed in the hope that it will be useful,
|
12 |
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
-
* Lesser General Public License for more details.
|
15 |
-
*
|
16 |
-
* You should have received a copy of the GNU Lesser General Public
|
17 |
-
* License along with this library; if not, write to the Free Software
|
18 |
-
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
19 |
-
*
|
20 |
-
* Google Analytics is a registered trademark of Google Inc.
|
21 |
-
*
|
22 |
-
* @link http://code.google.com/p/php-ga
|
23 |
-
*
|
24 |
-
* @license http://www.gnu.org/licenses/lgpl.html
|
25 |
-
* @author Thomas Bachem <tb@unitedprototype.com>
|
26 |
-
* @copyright Copyright (c) 2010 United Prototype GmbH (http://unitedprototype.com)
|
27 |
-
*/
|
28 |
-
|
29 |
-
namespace UnitedPrototype\GoogleAnalytics\Internals;
|
30 |
-
|
31 |
-
/**
|
32 |
-
* This is nearly a 1:1 PHP port of the gaforflash X10 class code.
|
33 |
-
*
|
34 |
-
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/data/X10.as
|
35 |
-
*/
|
36 |
-
class X10 {
|
37 |
-
|
38 |
-
/**
|
39 |
-
* @var array
|
40 |
-
*/
|
41 |
-
protected $projectData = array();
|
42 |
-
|
43 |
-
|
44 |
-
/**
|
45 |
-
* @var string
|
46 |
-
*/
|
47 |
-
protected $KEY = 'k';
|
48 |
-
|
49 |
-
/**
|
50 |
-
* @var string
|
51 |
-
*/
|
52 |
-
protected $VALUE = 'v';
|
53 |
-
|
54 |
-
/**
|
55 |
-
* @var array
|
56 |
-
*/
|
57 |
-
protected $SET = array('k', 'v');
|
58 |
-
|
59 |
-
/**
|
60 |
-
* Opening delimiter for wrapping a set of values belonging to the same type.
|
61 |
-
* @var string
|
62 |
-
*/
|
63 |
-
protected $DELIM_BEGIN = '(';
|
64 |
-
|
65 |
-
/**
|
66 |
-
* Closing delimiter for wrapping a set of values belonging to the same type.
|
67 |
-
* @var string
|
68 |
-
*/
|
69 |
-
protected $DELIM_END = ')';
|
70 |
-
|
71 |
-
/**
|
72 |
-
* Delimiter between two consecutive num/value pairs.
|
73 |
-
* @var string
|
74 |
-
*/
|
75 |
-
protected $DELIM_SET = '*';
|
76 |
-
|
77 |
-
/**
|
78 |
-
* Delimiter between a num and its corresponding value.
|
79 |
-
* @var string
|
80 |
-
*/
|
81 |
-
protected $DELIM_NUM_VALUE = '!';
|
82 |
-
|
83 |
-
/**
|
84 |
-
* Mapping of escapable characters to their escaped forms.
|
85 |
-
*
|
86 |
-
* @var array
|
87 |
-
*/
|
88 |
-
protected $ESCAPE_CHAR_MAP = array(
|
89 |
-
"'" => "'0",
|
90 |
-
')' => "'1",
|
91 |
-
'*' => "'2",
|
92 |
-
'!' => "'3",
|
93 |
-
);
|
94 |
-
|
95 |
-
/**
|
96 |
-
* @var int
|
97 |
-
*/
|
98 |
-
protected $MINIMUM = 1;
|
99 |
-
|
100 |
-
|
101 |
-
/**
|
102 |
-
* @const int
|
103 |
-
*/
|
104 |
-
const OBJECT_KEY_NUM = 1;
|
105 |
-
/**
|
106 |
-
* @const int
|
107 |
-
*/
|
108 |
-
const TYPE_KEY_NUM = 2;
|
109 |
-
/**
|
110 |
-
* @const int
|
111 |
-
*/
|
112 |
-
const LABEL_KEY_NUM = 3;
|
113 |
-
/**
|
114 |
-
* @const int
|
115 |
-
*/
|
116 |
-
const VALUE_VALUE_NUM = 1;
|
117 |
-
|
118 |
-
|
119 |
-
/**
|
120 |
-
* @param int $projectId
|
121 |
-
* @return bool
|
122 |
-
*/
|
123 |
-
protected function hasProject($projectId) {
|
124 |
-
return isset($this->projectData[$projectId]);
|
125 |
-
}
|
126 |
-
|
127 |
-
/**
|
128 |
-
* @param int $projectId
|
129 |
-
* @param int $num
|
130 |
-
* @param mixed $value
|
131 |
-
*/
|
132 |
-
public function setKey($projectId, $num, $value) {
|
133 |
-
$this->setInternal($projectId, $this->KEY, $num, $value);
|
134 |
-
}
|
135 |
-
|
136 |
-
/**
|
137 |
-
* @param int $projectId
|
138 |
-
* @param int $num
|
139 |
-
* @return mixed
|
140 |
-
*/
|
141 |
-
public function getKey($projectId, $num) {
|
142 |
-
return $this->getInternal($projectId, $this->KEY, $num);
|
143 |
-
}
|
144 |
-
|
145 |
-
/**
|
146 |
-
* @param int $projectId
|
147 |
-
*/
|
148 |
-
public function clearKey($projectId) {
|
149 |
-
$this->clearInternal($projectId, $this->KEY);
|
150 |
-
}
|
151 |
-
|
152 |
-
/**
|
153 |
-
* @param int $projectId
|
154 |
-
* @param int $num
|
155 |
-
* @param mixed $value
|
156 |
-
*/
|
157 |
-
public function setValue($projectId, $num, $value) {
|
158 |
-
$this->setInternal($projectId, $this->VALUE, $num, $value);
|
159 |
-
}
|
160 |
-
|
161 |
-
/**
|
162 |
-
* @param int $projectId
|
163 |
-
* @param int $num
|
164 |
-
* @return mixed
|
165 |
-
*/
|
166 |
-
public function getValue($projectId, $num) {
|
167 |
-
return $this->getInternal($projectId, $this->VALUE, $num);
|
168 |
-
}
|
169 |
-
|
170 |
-
/**
|
171 |
-
* @param int $projectId
|
172 |
-
*/
|
173 |
-
public function clearValue($projectId) {
|
174 |
-
$this->clearInternal($projectId, $this->VALUE);
|
175 |
-
}
|
176 |
-
|
177 |
-
/**
|
178 |
-
* Shared internal implementation for setting an X10 data type.
|
179 |
-
*
|
180 |
-
* @param int $projectId
|
181 |
-
* @param string $type
|
182 |
-
* @param int $num
|
183 |
-
* @param mixed $value
|
184 |
-
*/
|
185 |
-
protected function setInternal($projectId, $type, $num, $value) {
|
186 |
-
if(!isset($this->projectData[$projectId])) {
|
187 |
-
$this->projectData[$projectId] = array();
|
188 |
-
}
|
189 |
-
if(!isset($this->projectData[$projectId][$type])) {
|
190 |
-
$this->projectData[$projectId][$type] = array();
|
191 |
-
}
|
192 |
-
|
193 |
-
$this->projectData[$projectId][$type][$num] = $value;
|
194 |
-
}
|
195 |
-
|
196 |
-
/**
|
197 |
-
* Shared internal implementation for getting an X10 data type.
|
198 |
-
*
|
199 |
-
* @param int $projectId
|
200 |
-
* @param string $type
|
201 |
-
* @param int $num
|
202 |
-
* @return mixed
|
203 |
-
*/
|
204 |
-
protected function getInternal($projectId, $type, $num) {
|
205 |
-
if(isset($this->projectData[$projectId][$type][$num])) {
|
206 |
-
return $this->projectData[$projectId][$type][$num];
|
207 |
-
} else {
|
208 |
-
return null;
|
209 |
-
}
|
210 |
-
}
|
211 |
-
|
212 |
-
/**
|
213 |
-
* Shared internal implementation for clearing all X10 data of a type from a
|
214 |
-
* certain project.
|
215 |
-
*
|
216 |
-
* @param int $projectId
|
217 |
-
* @param string $type
|
218 |
-
*/
|
219 |
-
protected function clearInternal($projectId, $type) {
|
220 |
-
if(isset($this->projectData[$projectId]) && isset($this->projectData[$projectId][$type])) {
|
221 |
-
unset($this->projectData[$projectId][$type]);
|
222 |
-
}
|
223 |
-
}
|
224 |
-
|
225 |
-
/**
|
226 |
-
* Escape X10 string values to remove ambiguity for special characters.
|
227 |
-
*
|
228 |
-
* @see X10::$escapeCharMap
|
229 |
-
* @param string $value
|
230 |
-
* @return string
|
231 |
-
*/
|
232 |
-
protected function escapeExtensibleValue($value) {
|
233 |
-
$result = '';
|
234 |
-
|
235 |
-
$value = (string)$value;
|
236 |
-
$length = strlen($value);
|
237 |
-
for($i = 0; $i < $length; $i++) {
|
238 |
-
$char = $value[$i];
|
239 |
-
|
240 |
-
if(isset($this->ESCAPE_CHAR_MAP[$char])) {
|
241 |
-
$result .= $this->ESCAPE_CHAR_MAP[$char];
|
242 |
-
} else {
|
243 |
-
$result .= $char;
|
244 |
-
}
|
245 |
-
}
|
246 |
-
|
247 |
-
return $result;
|
248 |
-
}
|
249 |
-
|
250 |
-
/**
|
251 |
-
* Given a data array for a certain type, render its string encoding.
|
252 |
-
*
|
253 |
-
* @param array $data
|
254 |
-
* @return string
|
255 |
-
*/
|
256 |
-
protected function renderDataType(array $data) {
|
257 |
-
$result = array();
|
258 |
-
|
259 |
-
$lastI = 0;
|
260 |
-
ksort($data, SORT_NUMERIC);
|
261 |
-
foreach($data as $i => $entry) {
|
262 |
-
if(isset($entry)) {
|
263 |
-
$str = '';
|
264 |
-
|
265 |
-
// Check if we need to append the number. If the last number was
|
266 |
-
// outputted, or if this is the assumed minimum, then we don't.
|
267 |
-
if($i != $this->MINIMUM && $i - 1 != $lastI) {
|
268 |
-
$str .= $i;
|
269 |
-
$str .= $this->DELIM_NUM_VALUE;
|
270 |
-
}
|
271 |
-
|
272 |
-
$str .= $this->escapeExtensibleValue($entry);
|
273 |
-
$result[] = $str;
|
274 |
-
}
|
275 |
-
|
276 |
-
$lastI = $i;
|
277 |
-
}
|
278 |
-
|
279 |
-
return $this->DELIM_BEGIN . implode($this->DELIM_SET, $result) . $this->DELIM_END;
|
280 |
-
}
|
281 |
-
|
282 |
-
/**
|
283 |
-
* Given a project array, render its string encoding.
|
284 |
-
*
|
285 |
-
* @param array $project
|
286 |
-
* @return string
|
287 |
-
*/
|
288 |
-
protected function renderProject(array $project) {
|
289 |
-
$result = '';
|
290 |
-
|
291 |
-
// Do we need to output the type string? As an optimization we do not
|
292 |
-
// output the type string if it's the first type, or if the previous
|
293 |
-
// type was present.
|
294 |
-
$needTypeQualifier = false;
|
295 |
-
|
296 |
-
$length = count($this->SET);
|
297 |
-
for($i = 0; $i < $length; $i++) {
|
298 |
-
if(isset($project[$this->SET[$i]])) {
|
299 |
-
$data = $project[$this->SET[$i]];
|
300 |
-
|
301 |
-
if($needTypeQualifier) {
|
302 |
-
$result .= $this->SET[$i];
|
303 |
-
}
|
304 |
-
$result .= $this->renderDataType($data);
|
305 |
-
$needTypeQualifier = false;
|
306 |
-
} else {
|
307 |
-
$needTypeQualifier = true;
|
308 |
-
}
|
309 |
-
}
|
310 |
-
|
311 |
-
return $result;
|
312 |
-
}
|
313 |
-
|
314 |
-
/**
|
315 |
-
* Generates the URL parameter string for the current internal extensible data state.
|
316 |
-
*
|
317 |
-
* @return string
|
318 |
-
*/
|
319 |
-
public function renderUrlString() {
|
320 |
-
$result = '';
|
321 |
-
|
322 |
-
foreach($this->projectData as $projectId => $project) {
|
323 |
-
$result .= $projectId . $this->renderProject($project);
|
324 |
-
}
|
325 |
-
|
326 |
-
return $result;
|
327 |
-
}
|
328 |
-
|
329 |
-
}
|
330 |
-
|
331 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Sluice/Connect/lib/GoogleAnalytics/Item.php
DELETED
@@ -1,180 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Generic Server-Side Google Analytics PHP Client
|
5 |
-
*
|
6 |
-
* This library is free software; you can redistribute it and/or
|
7 |
-
* modify it under the terms of the GNU Lesser General Public
|
8 |
-
* License (LGPL) as published by the Free Software Foundation; either
|
9 |
-
* version 3 of the License, or (at your option) any later version.
|
10 |
-
*
|
11 |
-
* This library is distributed in the hope that it will be useful,
|
12 |
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
-
* Lesser General Public License for more details.
|
15 |
-
*
|
16 |
-
* You should have received a copy of the GNU Lesser General Public
|
17 |
-
* License along with this library; if not, write to the Free Software
|
18 |
-
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
19 |
-
*
|
20 |
-
* Google Analytics is a registered trademark of Google Inc.
|
21 |
-
*
|
22 |
-
* @link http://code.google.com/p/php-ga
|
23 |
-
*
|
24 |
-
* @license http://www.gnu.org/licenses/lgpl.html
|
25 |
-
* @author Thomas Bachem <tb@unitedprototype.com>
|
26 |
-
* @copyright Copyright (c) 2010 United Prototype GmbH (http://unitedprototype.com)
|
27 |
-
*/
|
28 |
-
|
29 |
-
namespace UnitedPrototype\GoogleAnalytics;
|
30 |
-
|
31 |
-
/**
|
32 |
-
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/ecommerce/Item.as
|
33 |
-
*/
|
34 |
-
class Item {
|
35 |
-
|
36 |
-
/**
|
37 |
-
* Order ID, e.g. "a2343898", will be mapped to "utmtid" parameter
|
38 |
-
*
|
39 |
-
* @see Internals\ParameterHolder::$utmtid
|
40 |
-
* @var string
|
41 |
-
*/
|
42 |
-
protected $orderId;
|
43 |
-
|
44 |
-
/**
|
45 |
-
* Product Code. This is the sku code for a given product, e.g. "989898ajssi",
|
46 |
-
* will be mapped to "utmipc" parameter
|
47 |
-
*
|
48 |
-
* @see Internals\ParameterHolder::$utmipc
|
49 |
-
* @var string
|
50 |
-
*/
|
51 |
-
protected $sku;
|
52 |
-
|
53 |
-
/**
|
54 |
-
* Product Name, e.g. "T-Shirt", will be mapped to "utmipn" parameter
|
55 |
-
*
|
56 |
-
* @see Internals\ParameterHolder::$utmipn
|
57 |
-
* @var string
|
58 |
-
*/
|
59 |
-
protected $name;
|
60 |
-
|
61 |
-
/**
|
62 |
-
* Variations on an item, e.g. "white", "black", "green" etc., will be mapped
|
63 |
-
* to "utmiva" parameter
|
64 |
-
*
|
65 |
-
* @see Internals\ParameterHolder::$utmiva
|
66 |
-
* @var string
|
67 |
-
*/
|
68 |
-
protected $variation;
|
69 |
-
|
70 |
-
/**
|
71 |
-
* Unit Price. Value is set to numbers only (e.g. 19.95), will be mapped to
|
72 |
-
* "utmipr" parameter
|
73 |
-
*
|
74 |
-
* @see Internals\ParameterHolder::$utmipr
|
75 |
-
* @var float
|
76 |
-
*/
|
77 |
-
protected $price;
|
78 |
-
|
79 |
-
/**
|
80 |
-
* Unit Quantity, e.g. 4, will be mapped to "utmiqt" parameter
|
81 |
-
*
|
82 |
-
* @see Internals\ParameterHolder::$utmiqt
|
83 |
-
* @var int
|
84 |
-
*/
|
85 |
-
protected $quantity = 1;
|
86 |
-
|
87 |
-
|
88 |
-
public function validate() {
|
89 |
-
if($this->sku === null) {
|
90 |
-
Tracker::_raiseError('Items need to have a sku/product code defined.', __METHOD__);
|
91 |
-
}
|
92 |
-
}
|
93 |
-
|
94 |
-
/**
|
95 |
-
* @return string
|
96 |
-
*/
|
97 |
-
public function getOrderId() {
|
98 |
-
return $this->orderId;
|
99 |
-
}
|
100 |
-
|
101 |
-
/**
|
102 |
-
* @param string $orderId
|
103 |
-
*/
|
104 |
-
public function setOrderId($orderId) {
|
105 |
-
$this->orderId = $orderId;
|
106 |
-
}
|
107 |
-
|
108 |
-
/**
|
109 |
-
* @return string
|
110 |
-
*/
|
111 |
-
public function getSku() {
|
112 |
-
return $this->sku;
|
113 |
-
}
|
114 |
-
|
115 |
-
/**
|
116 |
-
* @param string $sku
|
117 |
-
*/
|
118 |
-
public function setSku($sku) {
|
119 |
-
$this->sku = $sku;
|
120 |
-
}
|
121 |
-
|
122 |
-
/**
|
123 |
-
* @return string
|
124 |
-
*/
|
125 |
-
public function getName() {
|
126 |
-
return $this->name;
|
127 |
-
}
|
128 |
-
|
129 |
-
/**
|
130 |
-
* @param string $name
|
131 |
-
*/
|
132 |
-
public function setName($name) {
|
133 |
-
$this->name = $name;
|
134 |
-
}
|
135 |
-
|
136 |
-
/**
|
137 |
-
* @return string
|
138 |
-
*/
|
139 |
-
public function getVariation() {
|
140 |
-
return $this->variation;
|
141 |
-
}
|
142 |
-
|
143 |
-
/**
|
144 |
-
* @param string $variation
|
145 |
-
*/
|
146 |
-
public function setVariation($variation) {
|
147 |
-
$this->variation = $variation;
|
148 |
-
}
|
149 |
-
|
150 |
-
/**
|
151 |
-
* @return float
|
152 |
-
*/
|
153 |
-
public function getPrice() {
|
154 |
-
return $this->price;
|
155 |
-
}
|
156 |
-
|
157 |
-
/**
|
158 |
-
* @param float $price
|
159 |
-
*/
|
160 |
-
public function setPrice($price) {
|
161 |
-
$this->price = (float)$price;
|
162 |
-
}
|
163 |
-
|
164 |
-
/**
|
165 |
-
* @return int
|
166 |
-
*/
|
167 |
-
public function getQuantity() {
|
168 |
-
return $this->quantity;
|
169 |
-
}
|
170 |
-
|
171 |
-
/**
|
172 |
-
* @param int $quantity
|
173 |
-
*/
|
174 |
-
public function setQuantity($quantity) {
|
175 |
-
$this->quantity = (int)$quantity;
|
176 |
-
}
|
177 |
-
|
178 |
-
}
|
179 |
-
|
180 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Sluice/Connect/lib/GoogleAnalytics/Page.php
DELETED
@@ -1,172 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Generic Server-Side Google Analytics PHP Client
|
5 |
-
*
|
6 |
-
* This library is free software; you can redistribute it and/or
|
7 |
-
* modify it under the terms of the GNU Lesser General Public
|
8 |
-
* License (LGPL) as published by the Free Software Foundation; either
|
9 |
-
* version 3 of the License, or (at your option) any later version.
|
10 |
-
*
|
11 |
-
* This library is distributed in the hope that it will be useful,
|
12 |
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
-
* Lesser General Public License for more details.
|
15 |
-
*
|
16 |
-
* You should have received a copy of the GNU Lesser General Public
|
17 |
-
* License along with this library; if not, write to the Free Software
|
18 |
-
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
19 |
-
*
|
20 |
-
* Google Analytics is a registered trademark of Google Inc.
|
21 |
-
*
|
22 |
-
* @link http://code.google.com/p/php-ga
|
23 |
-
*
|
24 |
-
* @license http://www.gnu.org/licenses/lgpl.html
|
25 |
-
* @author Thomas Bachem <tb@unitedprototype.com>
|
26 |
-
* @copyright Copyright (c) 2010 United Prototype GmbH (http://unitedprototype.com)
|
27 |
-
*/
|
28 |
-
|
29 |
-
namespace UnitedPrototype\GoogleAnalytics;
|
30 |
-
|
31 |
-
class Page {
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Page request URI, e.g. "/path/page.html", will be mapped to
|
35 |
-
* "utmp" parameter
|
36 |
-
*
|
37 |
-
* @see Internals\ParameterHolder::$utmp
|
38 |
-
* @var string
|
39 |
-
*/
|
40 |
-
protected $path;
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Page title, will be mapped to "utmdt" parameter
|
44 |
-
*
|
45 |
-
* @see Internals\ParameterHolder::$utmdt
|
46 |
-
* @var string
|
47 |
-
*/
|
48 |
-
protected $title;
|
49 |
-
|
50 |
-
/**
|
51 |
-
* Charset encoding (e.g. "UTF-8"), will be mapped to "utmcs" parameter
|
52 |
-
*
|
53 |
-
* @see Internals\ParameterHolder::$utmcs
|
54 |
-
* @var string
|
55 |
-
*/
|
56 |
-
protected $charset;
|
57 |
-
|
58 |
-
/**
|
59 |
-
* Referer URL, e.g. "http://www.example.com/path/page.html", will be
|
60 |
-
* mapped to "utmr" parameter
|
61 |
-
*
|
62 |
-
* @see Internals\ParameterHolder::$utmr
|
63 |
-
* @var string
|
64 |
-
*/
|
65 |
-
protected $referrer;
|
66 |
-
|
67 |
-
/**
|
68 |
-
* Page load time in milliseconds, will be encoded into "utme" parameter.
|
69 |
-
*
|
70 |
-
* @see Internals\ParameterHolder::$utme
|
71 |
-
* @var int
|
72 |
-
*/
|
73 |
-
protected $loadTime;
|
74 |
-
|
75 |
-
|
76 |
-
/**
|
77 |
-
* Constant to mark referrer as a site-internal one.
|
78 |
-
*
|
79 |
-
* @see Page::$referrer
|
80 |
-
* @const string
|
81 |
-
*/
|
82 |
-
const REFERRER_INTERNAL = '0';
|
83 |
-
|
84 |
-
|
85 |
-
/**
|
86 |
-
* @param string $path
|
87 |
-
*/
|
88 |
-
public function __construct($path) {
|
89 |
-
$this->setPath($path);
|
90 |
-
}
|
91 |
-
|
92 |
-
/**
|
93 |
-
* @param string $path
|
94 |
-
*/
|
95 |
-
public function setPath($path) {
|
96 |
-
if($path && $path[0] != '/') {
|
97 |
-
Tracker::_raiseError('The page path should always start with a slash ("/").', __METHOD__);
|
98 |
-
}
|
99 |
-
|
100 |
-
$this->path = $path;
|
101 |
-
}
|
102 |
-
|
103 |
-
/**
|
104 |
-
* @return string
|
105 |
-
*/
|
106 |
-
public function getPath() {
|
107 |
-
return $this->path;
|
108 |
-
}
|
109 |
-
|
110 |
-
/**
|
111 |
-
* @param string $title
|
112 |
-
*/
|
113 |
-
public function setTitle($title) {
|
114 |
-
$this->title = $title;
|
115 |
-
}
|
116 |
-
|
117 |
-
/**
|
118 |
-
* @return string
|
119 |
-
*/
|
120 |
-
public function getTitle() {
|
121 |
-
return $this->title;
|
122 |
-
}
|
123 |
-
|
124 |
-
/**
|
125 |
-
* @param string $charset
|
126 |
-
*/
|
127 |
-
public function setCharset($encoding) {
|
128 |
-
$this->charset = $encoding;
|
129 |
-
}
|
130 |
-
|
131 |
-
/**
|
132 |
-
* @return string
|
133 |
-
*/
|
134 |
-
public function getCharset() {
|
135 |
-
return $this->charset;
|
136 |
-
}
|
137 |
-
|
138 |
-
/**
|
139 |
-
* @param string $referrer
|
140 |
-
*/
|
141 |
-
public function setReferrer($referrer) {
|
142 |
-
$this->referrer = $referrer;
|
143 |
-
}
|
144 |
-
|
145 |
-
/**
|
146 |
-
* @return string
|
147 |
-
*/
|
148 |
-
public function getReferrer() {
|
149 |
-
return $this->referrer;
|
150 |
-
}
|
151 |
-
|
152 |
-
/**
|
153 |
-
* @param int $loadTime
|
154 |
-
*/
|
155 |
-
public function setLoadTime($loadTime) {
|
156 |
-
if((int)$loadTime != (float)$loadTime) {
|
157 |
-
return Tracker::_raiseError('Page load time must be specified in integer milliseconds.', __METHOD__);
|
158 |
-
}
|
159 |
-
|
160 |
-
$this->loadTime = (int)$loadTime;
|
161 |
-
}
|
162 |
-
|
163 |
-
/**
|
164 |
-
* @return int
|
165 |
-
*/
|
166 |
-
public function getLoadTime() {
|
167 |
-
return $this->loadTime;
|
168 |
-
}
|
169 |
-
|
170 |
-
}
|
171 |
-
|
172 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Sluice/Connect/lib/GoogleAnalytics/Session.php
DELETED
@@ -1,161 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Generic Server-Side Google Analytics PHP Client
|
5 |
-
*
|
6 |
-
* This library is free software; you can redistribute it and/or
|
7 |
-
* modify it under the terms of the GNU Lesser General Public
|
8 |
-
* License (LGPL) as published by the Free Software Foundation; either
|
9 |
-
* version 3 of the License, or (at your option) any later version.
|
10 |
-
*
|
11 |
-
* This library is distributed in the hope that it will be useful,
|
12 |
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
-
* Lesser General Public License for more details.
|
15 |
-
*
|
16 |
-
* You should have received a copy of the GNU Lesser General Public
|
17 |
-
* License along with this library; if not, write to the Free Software
|
18 |
-
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
19 |
-
*
|
20 |
-
* Google Analytics is a registered trademark of Google Inc.
|
21 |
-
*
|
22 |
-
* @link http://code.google.com/p/php-ga
|
23 |
-
*
|
24 |
-
* @license http://www.gnu.org/licenses/lgpl.html
|
25 |
-
* @author Thomas Bachem <tb@unitedprototype.com>
|
26 |
-
* @copyright Copyright (c) 2010 United Prototype GmbH (http://unitedprototype.com)
|
27 |
-
*/
|
28 |
-
|
29 |
-
namespace UnitedPrototype\GoogleAnalytics;
|
30 |
-
|
31 |
-
use UnitedPrototype\GoogleAnalytics\Internals\Util;
|
32 |
-
|
33 |
-
use DateTime;
|
34 |
-
|
35 |
-
/**
|
36 |
-
* You should serialize this object and store it in the user session to keep it
|
37 |
-
* persistent between requests (similar to the "__umtb" cookie of
|
38 |
-
* the GA Javascript client).
|
39 |
-
*/
|
40 |
-
class Session {
|
41 |
-
|
42 |
-
/**
|
43 |
-
* A unique per-session ID, will be mapped to "utmhid" parameter
|
44 |
-
*
|
45 |
-
* @see Internals\ParameterHolder::$utmhid
|
46 |
-
* @var int
|
47 |
-
*/
|
48 |
-
protected $sessionId;
|
49 |
-
|
50 |
-
/**
|
51 |
-
* The amount of pageviews that were tracked within this session so far,
|
52 |
-
* will be part of the "__utmb" cookie parameter.
|
53 |
-
*
|
54 |
-
* Will get incremented automatically upon each request.
|
55 |
-
*
|
56 |
-
* @see Internals\ParameterHolder::$__utmb
|
57 |
-
* @see Internals\Request\Request::buildHttpRequest()
|
58 |
-
* @var int
|
59 |
-
*/
|
60 |
-
protected $trackCount;
|
61 |
-
|
62 |
-
/**
|
63 |
-
* Timestamp of the start of this new session, will be part of the "__utmb"
|
64 |
-
* cookie parameter
|
65 |
-
*
|
66 |
-
* @see Internals\ParameterHolder::$__utmb
|
67 |
-
* @var DateTime
|
68 |
-
*/
|
69 |
-
protected $startTime;
|
70 |
-
|
71 |
-
|
72 |
-
public function __construct() {
|
73 |
-
$this->setSessionId($this->generateSessionId());
|
74 |
-
$this->setTrackCount(0);
|
75 |
-
$this->setStartTime(new DateTime());
|
76 |
-
}
|
77 |
-
|
78 |
-
/**
|
79 |
-
* Will extract information for the "trackCount" and "startTime"
|
80 |
-
* properties from the given "__utmb" cookie value.
|
81 |
-
*
|
82 |
-
* @see Internals\ParameterHolder::$__utmb
|
83 |
-
* @see Internals\Request\Request::buildCookieParameters()
|
84 |
-
* @param string $value
|
85 |
-
* @return $this
|
86 |
-
*/
|
87 |
-
public function fromUtmb($value) {
|
88 |
-
$parts = explode('.', $value);
|
89 |
-
if(count($parts) != 4) {
|
90 |
-
Tracker::_raiseError('The given "__utmb" cookie value is invalid.', __METHOD__);
|
91 |
-
return $this;
|
92 |
-
}
|
93 |
-
|
94 |
-
$this->setTrackCount($parts[1]);
|
95 |
-
$this->setStartTime(new DateTime('@' . $parts[3]));
|
96 |
-
|
97 |
-
// Allow chaining
|
98 |
-
return $this;
|
99 |
-
}
|
100 |
-
|
101 |
-
/**
|
102 |
-
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/core/DocumentInfo.as#52
|
103 |
-
* @return int
|
104 |
-
*/
|
105 |
-
protected function generateSessionId() {
|
106 |
-
// TODO: Integrate AdSense support
|
107 |
-
return Util::generate32bitRandom();
|
108 |
-
}
|
109 |
-
|
110 |
-
/**
|
111 |
-
* @return int
|
112 |
-
*/
|
113 |
-
public function getSessionId() {
|
114 |
-
return $this->sessionId;
|
115 |
-
}
|
116 |
-
|
117 |
-
/**
|
118 |
-
* @param int $sessionId
|
119 |
-
*/
|
120 |
-
public function setSessionId($sessionId) {
|
121 |
-
$this->sessionId = $sessionId;
|
122 |
-
}
|
123 |
-
|
124 |
-
/**
|
125 |
-
* @return int
|
126 |
-
*/
|
127 |
-
public function getTrackCount() {
|
128 |
-
return $this->trackCount;
|
129 |
-
}
|
130 |
-
|
131 |
-
/**
|
132 |
-
* @param int $trackCount
|
133 |
-
*/
|
134 |
-
public function setTrackCount($trackCount) {
|
135 |
-
$this->trackCount = (int)$trackCount;
|
136 |
-
}
|
137 |
-
|
138 |
-
/**
|
139 |
-
* @param int $byAmount
|
140 |
-
*/
|
141 |
-
public function increaseTrackCount($byAmount = 1) {
|
142 |
-
$this->trackCount += $byAmount;
|
143 |
-
}
|
144 |
-
|
145 |
-
/**
|
146 |
-
* @return DateTime
|
147 |
-
*/
|
148 |
-
public function getStartTime() {
|
149 |
-
return $this->startTime;
|
150 |
-
}
|
151 |
-
|
152 |
-
/**
|
153 |
-
* @param DateTime $startTime
|
154 |
-
*/
|
155 |
-
public function setStartTime(DateTime $startTime) {
|
156 |
-
$this->startTime = $startTime;
|
157 |
-
}
|
158 |
-
|
159 |
-
}
|
160 |
-
|
161 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Sluice/Connect/lib/GoogleAnalytics/SocialInteraction.php
DELETED
@@ -1,123 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Generic Server-Side Google Analytics PHP Client
|
5 |
-
*
|
6 |
-
* This library is free software; you can redistribute it and/or
|
7 |
-
* modify it under the terms of the GNU Lesser General Public
|
8 |
-
* License (LGPL) as published by the Free Software Foundation; either
|
9 |
-
* version 3 of the License, or (at your option) any later version.
|
10 |
-
*
|
11 |
-
* This library is distributed in the hope that it will be useful,
|
12 |
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
-
* Lesser General Public License for more details.
|
15 |
-
*
|
16 |
-
* You should have received a copy of the GNU Lesser General Public
|
17 |
-
* License along with this library; if not, write to the Free Software
|
18 |
-
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
19 |
-
*
|
20 |
-
* Google Analytics is a registered trademark of Google Inc.
|
21 |
-
*
|
22 |
-
* @link http://code.google.com/p/php-ga
|
23 |
-
*
|
24 |
-
* @license http://www.gnu.org/licenses/lgpl.html
|
25 |
-
* @author Thomas Bachem <tb@unitedprototype.com>
|
26 |
-
* @copyright Copyright (c) 2010 United Prototype GmbH (http://unitedprototype.com)
|
27 |
-
*/
|
28 |
-
|
29 |
-
namespace UnitedPrototype\GoogleAnalytics;
|
30 |
-
|
31 |
-
class SocialInteraction {
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Required. A string representing the social network being tracked (e.g. "Facebook", "Twitter", "LinkedIn", ...),
|
35 |
-
* will be mapped to "utmsn" parameter
|
36 |
-
*
|
37 |
-
* @see Internals\ParameterHolder::$utmsn
|
38 |
-
* @var string
|
39 |
-
*/
|
40 |
-
protected $network;
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Required. A string representing the social action being tracked (e.g. "Like", "Share", "Tweet", ...),
|
44 |
-
* will be mapped to "utmsa" parameter
|
45 |
-
*
|
46 |
-
* @see Internals\ParameterHolder::$utmsa
|
47 |
-
* @var string
|
48 |
-
*/
|
49 |
-
protected $action;
|
50 |
-
|
51 |
-
/**
|
52 |
-
* Optional. A string representing the URL (or resource) which receives the action. For example,
|
53 |
-
* if a user clicks the Like button on a page on a site, the the target might be set to the title
|
54 |
-
* of the page, or an ID used to identify the page in a content management system. In many cases,
|
55 |
-
* the page you Like is the same page you are on. So if this parameter is not given, we will default
|
56 |
-
* to using the path of the corresponding Page object.
|
57 |
-
*
|
58 |
-
* @see Internals\ParameterHolder::$utmsid
|
59 |
-
* @var string
|
60 |
-
*/
|
61 |
-
protected $target;
|
62 |
-
|
63 |
-
|
64 |
-
/**
|
65 |
-
* @param string $path
|
66 |
-
*/
|
67 |
-
public function __construct($network = null, $action = null, $target = null) {
|
68 |
-
if($network !== null) $this->setNetwork($network);
|
69 |
-
if($action !== null) $this->setAction($action);
|
70 |
-
if($target !== null) $this->setTarget($target);
|
71 |
-
}
|
72 |
-
|
73 |
-
public function validate() {
|
74 |
-
if($this->network === null || $this->action === null) {
|
75 |
-
Tracker::_raiseError('Social interactions need to have at least the "network" and "action" attributes defined.', __METHOD__);
|
76 |
-
}
|
77 |
-
}
|
78 |
-
|
79 |
-
/**
|
80 |
-
* @param string $network
|
81 |
-
*/
|
82 |
-
public function setNetwork($network) {
|
83 |
-
$this->network = $network;
|
84 |
-
}
|
85 |
-
|
86 |
-
/**
|
87 |
-
* @return string
|
88 |
-
*/
|
89 |
-
public function getNetwork() {
|
90 |
-
return $this->network;
|
91 |
-
}
|
92 |
-
|
93 |
-
/**
|
94 |
-
* @param string $action
|
95 |
-
*/
|
96 |
-
public function setAction($action) {
|
97 |
-
$this->action = $action;
|
98 |
-
}
|
99 |
-
|
100 |
-
/**
|
101 |
-
* @return string
|
102 |
-
*/
|
103 |
-
public function getAction() {
|
104 |
-
return $this->action;
|
105 |
-
}
|
106 |
-
|
107 |
-
/**
|
108 |
-
* @param string $target
|
109 |
-
*/
|
110 |
-
public function setTarget($target) {
|
111 |
-
$this->target = $target;
|
112 |
-
}
|
113 |
-
|
114 |
-
/**
|
115 |
-
* @return string
|
116 |
-
*/
|
117 |
-
public function getTarget() {
|
118 |
-
return $this->target;
|
119 |
-
}
|
120 |
-
|
121 |
-
}
|
122 |
-
|
123 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Sluice/Connect/lib/GoogleAnalytics/Tracker.php
DELETED
@@ -1,344 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Generic Server-Side Google Analytics PHP Client
|
5 |
-
*
|
6 |
-
* This library is free software; you can redistribute it and/or
|
7 |
-
* modify it under the terms of the GNU Lesser General Public
|
8 |
-
* License (LGPL) as published by the Free Software Foundation; either
|
9 |
-
* version 3 of the License, or (at your option) any later version.
|
10 |
-
*
|
11 |
-
* This library is distributed in the hope that it will be useful,
|
12 |
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
-
* Lesser General Public License for more details.
|
15 |
-
*
|
16 |
-
* You should have received a copy of the GNU Lesser General Public
|
17 |
-
* License along with this library; if not, write to the Free Software
|
18 |
-
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
19 |
-
*
|
20 |
-
* Google Analytics is a registered trademark of Google Inc.
|
21 |
-
*
|
22 |
-
* @link http://code.google.com/p/php-ga
|
23 |
-
*
|
24 |
-
* @license http://www.gnu.org/licenses/lgpl.html
|
25 |
-
* @author Thomas Bachem <tb@unitedprototype.com>
|
26 |
-
* @copyright Copyright (c) 2010 United Prototype GmbH (http://unitedprototype.com)
|
27 |
-
*/
|
28 |
-
|
29 |
-
namespace UnitedPrototype\GoogleAnalytics;
|
30 |
-
|
31 |
-
use UnitedPrototype\GoogleAnalytics\Internals\Util;
|
32 |
-
use UnitedPrototype\GoogleAnalytics\Internals\Request\PageviewRequest;
|
33 |
-
use UnitedPrototype\GoogleAnalytics\Internals\Request\EventRequest;
|
34 |
-
use UnitedPrototype\GoogleAnalytics\Internals\Request\TransactionRequest;
|
35 |
-
use UnitedPrototype\GoogleAnalytics\Internals\Request\ItemRequest;
|
36 |
-
use UnitedPrototype\GoogleAnalytics\Internals\Request\SocialInteractionRequest;
|
37 |
-
|
38 |
-
class Tracker {
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Google Analytics client version on which this library is built upon,
|
42 |
-
* will be mapped to "utmwv" parameter.
|
43 |
-
*
|
44 |
-
* This doesn't necessarily mean that all features of the corresponding
|
45 |
-
* ga.js version are implemented but rather that the requests comply
|
46 |
-
* with these of ga.js.
|
47 |
-
*
|
48 |
-
* @link http://code.google.com/apis/analytics/docs/gaJS/changelog.html
|
49 |
-
* @const string
|
50 |
-
*/
|
51 |
-
const VERSION = '5.2.5'; // As of 25.02.2012
|
52 |
-
|
53 |
-
|
54 |
-
/**
|
55 |
-
* The configuration to use for all tracker instances.
|
56 |
-
*
|
57 |
-
* @var \UnitedPrototype\GoogleAnalytics\Config
|
58 |
-
*/
|
59 |
-
protected static $config;
|
60 |
-
|
61 |
-
/**
|
62 |
-
* Google Analytics account ID, e.g. "UA-1234567-8", will be mapped to
|
63 |
-
* "utmac" parameter
|
64 |
-
*
|
65 |
-
* @see Internals\ParameterHolder::$utmac
|
66 |
-
* @var string
|
67 |
-
*/
|
68 |
-
protected $accountId;
|
69 |
-
|
70 |
-
/**
|
71 |
-
* Host Name, e.g. "www.example.com", will be mapped to "utmhn" parameter
|
72 |
-
*
|
73 |
-
* @see Internals\ParameterHolder::$utmhn
|
74 |
-
* @var string
|
75 |
-
*/
|
76 |
-
protected $domainName;
|
77 |
-
|
78 |
-
/**
|
79 |
-
* Whether to generate a unique domain hash, default is true to be consistent
|
80 |
-
* with the GA Javascript Client
|
81 |
-
*
|
82 |
-
* @link http://code.google.com/apis/analytics/docs/tracking/gaTrackingSite.html#setAllowHash
|
83 |
-
* @see Internals\Request\Request::generateDomainHash()
|
84 |
-
* @var bool
|
85 |
-
*/
|
86 |
-
protected $allowHash = true;
|
87 |
-
|
88 |
-
/**
|
89 |
-
* @var array
|
90 |
-
*/
|
91 |
-
protected $customVariables = array();
|
92 |
-
|
93 |
-
/**
|
94 |
-
* @var \UnitedPrototype\GoogleAnalytics\Campaign
|
95 |
-
*/
|
96 |
-
protected $campaign;
|
97 |
-
|
98 |
-
|
99 |
-
/**
|
100 |
-
* @param string $accountId
|
101 |
-
* @param string $domainName
|
102 |
-
* @param \UnitedPrototype\GoogleAnalytics\Config $config
|
103 |
-
*/
|
104 |
-
public function __construct($accountId, $domainName, Config $config = null) {
|
105 |
-
static::setConfig($config ? $config : new Config());
|
106 |
-
|
107 |
-
$this->setAccountId($accountId);
|
108 |
-
$this->setDomainName($domainName);
|
109 |
-
}
|
110 |
-
|
111 |
-
/**
|
112 |
-
* @return \UnitedPrototype\GoogleAnalytics\Config
|
113 |
-
*/
|
114 |
-
public static function getConfig() {
|
115 |
-
return static::$config;
|
116 |
-
}
|
117 |
-
|
118 |
-
/**
|
119 |
-
* @param \UnitedPrototype\GoogleAnalytics\Config $value
|
120 |
-
*/
|
121 |
-
public static function setConfig(Config $value) {
|
122 |
-
static::$config = $value;
|
123 |
-
}
|
124 |
-
|
125 |
-
/**
|
126 |
-
* @param string $value
|
127 |
-
*/
|
128 |
-
public function setAccountId($value) {
|
129 |
-
if(!preg_match('/^(UA|MO)-[0-9]*-[0-9]*$/', $value)) {
|
130 |
-
static::_raiseError('"' . $value . '" is not a valid Google Analytics account ID.', __METHOD__);
|
131 |
-
}
|
132 |
-
|
133 |
-
$this->accountId = $value;
|
134 |
-
}
|
135 |
-
|
136 |
-
/**
|
137 |
-
* @return string
|
138 |
-
*/
|
139 |
-
public function getAccountId() {
|
140 |
-
return $this->accountId;
|
141 |
-
}
|
142 |
-
|
143 |
-
/**
|
144 |
-
* @param string $value
|
145 |
-
*/
|
146 |
-
public function setDomainName($value) {
|
147 |
-
$this->domainName = $value;
|
148 |
-
}
|
149 |
-
|
150 |
-
/**
|
151 |
-
* @return string
|
152 |
-
*/
|
153 |
-
public function getDomainName() {
|
154 |
-
return $this->domainName;
|
155 |
-
}
|
156 |
-
|
157 |
-
/**
|
158 |
-
* @param bool $value
|
159 |
-
*/
|
160 |
-
public function setAllowHash($value) {
|
161 |
-
$this->allowHash = (bool)$value;
|
162 |
-
}
|
163 |
-
|
164 |
-
/**
|
165 |
-
* @return bool
|
166 |
-
*/
|
167 |
-
public function getAllowHash() {
|
168 |
-
return $this->allowHash;
|
169 |
-
}
|
170 |
-
|
171 |
-
/**
|
172 |
-
* Equivalent of _setCustomVar() in GA Javascript client.
|
173 |
-
*
|
174 |
-
* @link http://code.google.com/apis/analytics/docs/tracking/gaTrackingCustomVariables.html
|
175 |
-
* @param \UnitedPrototype\GoogleAnalytics\CustomVariable $customVariable
|
176 |
-
*/
|
177 |
-
public function addCustomVariable(CustomVariable $customVariable) {
|
178 |
-
// Ensure that all required parameters are set
|
179 |
-
$customVariable->validate();
|
180 |
-
|
181 |
-
$index = $customVariable->getIndex();
|
182 |
-
$this->customVariables[$index] = $customVariable;
|
183 |
-
}
|
184 |
-
|
185 |
-
/**
|
186 |
-
* @return \UnitedPrototype\GoogleAnalytics\CustomVariable[]
|
187 |
-
*/
|
188 |
-
public function getCustomVariables() {
|
189 |
-
return $this->customVariables;
|
190 |
-
}
|
191 |
-
|
192 |
-
/**
|
193 |
-
* Equivalent of _deleteCustomVar() in GA Javascript client.
|
194 |
-
*
|
195 |
-
* @param int $index
|
196 |
-
*/
|
197 |
-
public function removeCustomVariable($index) {
|
198 |
-
unset($this->customVariables[$index]);
|
199 |
-
}
|
200 |
-
|
201 |
-
/**
|
202 |
-
* @param \UnitedPrototype\GoogleAnalytics\Campaign $campaign Isn't really optional, but can be set to null
|
203 |
-
*/
|
204 |
-
public function setCampaign(Campaign $campaign = null) {
|
205 |
-
if($campaign) {
|
206 |
-
// Ensure that all required parameters are set
|
207 |
-
$campaign->validate();
|
208 |
-
}
|
209 |
-
|
210 |
-
$this->campaign = $campaign;
|
211 |
-
}
|
212 |
-
|
213 |
-
/**
|
214 |
-
* @return \UnitedPrototype\GoogleAnalytics\Campaign|null
|
215 |
-
*/
|
216 |
-
public function getCampaign() {
|
217 |
-
return $this->campaign;
|
218 |
-
}
|
219 |
-
|
220 |
-
/**
|
221 |
-
* Equivalent of _trackPageview() in GA Javascript client.
|
222 |
-
*
|
223 |
-
* @link http://code.google.com/apis/analytics/docs/gaJS/gaJSApiBasicConfiguration.html#_gat.GA_Tracker_._trackPageview
|
224 |
-
* @param \UnitedPrototype\GoogleAnalytics\Page $page
|
225 |
-
* @param \UnitedPrototype\GoogleAnalytics\Session $session
|
226 |
-
* @param \UnitedPrototype\GoogleAnalytics\Visitor $visitor
|
227 |
-
*/
|
228 |
-
public function trackPageview(Page $page, Session $session, Visitor $visitor) {
|
229 |
-
$request = new PageviewRequest(static::$config);
|
230 |
-
$request->setPage($page);
|
231 |
-
$request->setSession($session);
|
232 |
-
$request->setVisitor($visitor);
|
233 |
-
$request->setTracker($this);
|
234 |
-
$request->fire();
|
235 |
-
}
|
236 |
-
|
237 |
-
/**
|
238 |
-
* Equivalent of _trackEvent() in GA Javascript client.
|
239 |
-
*
|
240 |
-
* @link http://code.google.com/apis/analytics/docs/gaJS/gaJSApiEventTracking.html#_gat.GA_EventTracker_._trackEvent
|
241 |
-
* @param \UnitedPrototype\GoogleAnalytics\Event $event
|
242 |
-
* @param \UnitedPrototype\GoogleAnalytics\Session $session
|
243 |
-
* @param \UnitedPrototype\GoogleAnalytics\Visitor $visitor
|
244 |
-
*/
|
245 |
-
public function trackEvent(Event $event, Session $session, Visitor $visitor) {
|
246 |
-
// Ensure that all required parameters are set
|
247 |
-
$event->validate();
|
248 |
-
|
249 |
-
$request = new EventRequest(static::$config);
|
250 |
-
$request->setEvent($event);
|
251 |
-
$request->setSession($session);
|
252 |
-
$request->setVisitor($visitor);
|
253 |
-
$request->setTracker($this);
|
254 |
-
$request->fire();
|
255 |
-
}
|
256 |
-
|
257 |
-
/**
|
258 |
-
* Combines _addTrans(), _addItem() (indirectly) and _trackTrans() of GA Javascript client.
|
259 |
-
* Although the naming of "_addTrans()" would suggest multiple possible transactions
|
260 |
-
* per request, there is just one allowed actually.
|
261 |
-
*
|
262 |
-
* @link http://code.google.com/apis/analytics/docs/gaJS/gaJSApiEcommerce.html#_gat.GA_Tracker_._addTrans
|
263 |
-
* @link http://code.google.com/apis/analytics/docs/gaJS/gaJSApiEcommerce.html#_gat.GA_Tracker_._addItem
|
264 |
-
* @link http://code.google.com/apis/analytics/docs/gaJS/gaJSApiEcommerce.html#_gat.GA_Tracker_._trackTrans
|
265 |
-
*
|
266 |
-
* @param \UnitedPrototype\GoogleAnalytics\Transaction $transaction
|
267 |
-
* @param \UnitedPrototype\GoogleAnalytics\Session $session
|
268 |
-
* @param \UnitedPrototype\GoogleAnalytics\Visitor $visitor
|
269 |
-
*/
|
270 |
-
public function trackTransaction(Transaction $transaction, Session $session, Visitor $visitor) {
|
271 |
-
// Ensure that all required parameters are set
|
272 |
-
$transaction->validate();
|
273 |
-
|
274 |
-
$request = new TransactionRequest(static::$config);
|
275 |
-
$request->setTransaction($transaction);
|
276 |
-
$request->setSession($session);
|
277 |
-
$request->setVisitor($visitor);
|
278 |
-
$request->setTracker($this);
|
279 |
-
$request->fire();
|
280 |
-
|
281 |
-
// Every item gets a separate request,
|
282 |
-
// see http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/v4/Tracker.as#312
|
283 |
-
foreach($transaction->getItems() as $item) {
|
284 |
-
// Ensure that all required parameters are set
|
285 |
-
$item->validate();
|
286 |
-
|
287 |
-
$request = new ItemRequest(static::$config);
|
288 |
-
$request->setItem($item);
|
289 |
-
$request->setSession($session);
|
290 |
-
$request->setVisitor($visitor);
|
291 |
-
$request->setTracker($this);
|
292 |
-
$request->fire();
|
293 |
-
}
|
294 |
-
}
|
295 |
-
|
296 |
-
/**
|
297 |
-
* Equivalent of _trackSocial() in GA Javascript client.
|
298 |
-
*
|
299 |
-
* @link http://code.google.com/apis/analytics/docs/tracking/gaTrackingSocial.html#settingUp
|
300 |
-
* @param \UnitedPrototype\GoogleAnalytics\SocialInteraction $socialInteraction
|
301 |
-
* @param \UnitedPrototype\GoogleAnalytics\Page $page
|
302 |
-
* @param \UnitedPrototype\GoogleAnalytics\Session $session
|
303 |
-
* @param \UnitedPrototype\GoogleAnalytics\Visitor $visitor
|
304 |
-
*/
|
305 |
-
public function trackSocial(SocialInteraction $socialInteraction, Page $page, Session $session, Visitor $visitor) {
|
306 |
-
$request = new SocialInteractionRequest(static::$config);
|
307 |
-
$request->setSocialInteraction($socialInteraction);
|
308 |
-
$request->setPage($page);
|
309 |
-
$request->setSession($session);
|
310 |
-
$request->setVisitor($visitor);
|
311 |
-
$request->setTracker($this);
|
312 |
-
$request->fire();
|
313 |
-
}
|
314 |
-
|
315 |
-
/**
|
316 |
-
* For internal use only. Will trigger an error according to the current
|
317 |
-
* Config::$errorSeverity setting.
|
318 |
-
*
|
319 |
-
* @see Config::$errorSeverity
|
320 |
-
* @param string $message
|
321 |
-
* @param string $method
|
322 |
-
*/
|
323 |
-
public static function _raiseError($message, $method) {
|
324 |
-
$method = str_replace(__NAMESPACE__ . '\\', '', $method);
|
325 |
-
$message = $method . '(): ' . $message;
|
326 |
-
|
327 |
-
$errorSeverity = isset(static::$config) ? static::$config->getErrorSeverity() : Config::ERROR_SEVERITY_EXCEPTIONS;
|
328 |
-
|
329 |
-
switch($errorSeverity) {
|
330 |
-
case Config::ERROR_SEVERITY_SILENCE:
|
331 |
-
// Do nothing
|
332 |
-
break;
|
333 |
-
case Config::ERROR_SEVERITY_WARNINGS:
|
334 |
-
trigger_error($message, E_USER_WARNING);
|
335 |
-
break;
|
336 |
-
case Config::ERROR_SEVERITY_EXCEPTIONS:
|
337 |
-
throw new Exception($message);
|
338 |
-
break;
|
339 |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Sluice/Connect/lib/GoogleAnalytics/Transaction.php
DELETED
@@ -1,252 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Generic Server-Side Google Analytics PHP Client
|
5 |
-
*
|
6 |
-
* This library is free software; you can redistribute it and/or
|
7 |
-
* modify it under the terms of the GNU Lesser General Public
|
8 |
-
* License (LGPL) as published by the Free Software Foundation; either
|
9 |
-
* version 3 of the License, or (at your option) any later version.
|
10 |
-
*
|
11 |
-
* This library is distributed in the hope that it will be useful,
|
12 |
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
-
* Lesser General Public License for more details.
|
15 |
-
*
|
16 |
-
* You should have received a copy of the GNU Lesser General Public
|
17 |
-
* License along with this library; if not, write to the Free Software
|
18 |
-
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
19 |
-
*
|
20 |
-
* Google Analytics is a registered trademark of Google Inc.
|
21 |
-
*
|
22 |
-
* @link http://code.google.com/p/php-ga
|
23 |
-
*
|
24 |
-
* @license http://www.gnu.org/licenses/lgpl.html
|
25 |
-
* @author Thomas Bachem <tb@unitedprototype.com>
|
26 |
-
* @copyright Copyright (c) 2010 United Prototype GmbH (http://unitedprototype.com)
|
27 |
-
*/
|
28 |
-
|
29 |
-
namespace UnitedPrototype\GoogleAnalytics;
|
30 |
-
|
31 |
-
/**
|
32 |
-
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/ecommerce/Transaction.as
|
33 |
-
*/
|
34 |
-
class Transaction {
|
35 |
-
|
36 |
-
/**
|
37 |
-
* Order ID, e.g. "a2343898", will be mapped to "utmtid" parameter
|
38 |
-
*
|
39 |
-
* @see Internals\ParameterHolder::$utmtid
|
40 |
-
* @var string
|
41 |
-
*/
|
42 |
-
protected $orderId;
|
43 |
-
|
44 |
-
/**
|
45 |
-
* Affiliation, Will be mapped to "utmtst" parameter
|
46 |
-
*
|
47 |
-
* @see Internals\ParameterHolder::$utmtst
|
48 |
-
* @var string
|
49 |
-
*/
|
50 |
-
protected $affiliation;
|
51 |
-
|
52 |
-
/**
|
53 |
-
* Total Cost, will be mapped to "utmtto" parameter
|
54 |
-
*
|
55 |
-
* @see Internals\ParameterHolder::$utmtto
|
56 |
-
* @var float
|
57 |
-
*/
|
58 |
-
protected $total;
|
59 |
-
|
60 |
-
/**
|
61 |
-
* Tax Cost, will be mapped to "utmttx" parameter
|
62 |
-
*
|
63 |
-
* @see Internals\ParameterHolder::$utmttx
|
64 |
-
* @var float
|
65 |
-
*/
|
66 |
-
protected $tax;
|
67 |
-
|
68 |
-
/**
|
69 |
-
* Shipping Cost, values as for unit and price, e.g. 3.95, will be mapped to
|
70 |
-
* "utmtsp" parameter
|
71 |
-
*
|
72 |
-
* @see Internals\ParameterHolder::$utmtsp
|
73 |
-
* @var float
|
74 |
-
*/
|
75 |
-
protected $shipping;
|
76 |
-
|
77 |
-
/**
|
78 |
-
* Billing City, e.g. "Cologne", will be mapped to "utmtci" parameter
|
79 |
-
*
|
80 |
-
* @see Internals\ParameterHolder::$utmtci
|
81 |
-
* @var string
|
82 |
-
*/
|
83 |
-
protected $city;
|
84 |
-
|
85 |
-
/**
|
86 |
-
* Billing Region, e.g. "North Rhine-Westphalia", will be mapped to "utmtrg" parameter
|
87 |
-
*
|
88 |
-
* @see Internals\ParameterHolder::$utmtrg
|
89 |
-
* @var string
|
90 |
-
*/
|
91 |
-
protected $region;
|
92 |
-
|
93 |
-
/**
|
94 |
-
* Billing Country, e.g. "Germany", will be mapped to "utmtco" parameter
|
95 |
-
*
|
96 |
-
* @see Internals\ParameterHolder::$utmtco
|
97 |
-
* @var string
|
98 |
-
*/
|
99 |
-
protected $country;
|
100 |
-
|
101 |
-
/**
|
102 |
-
* @see Transaction::addItem()
|
103 |
-
* @var \UnitedPrototype\GoogleAnalytics\Item[]
|
104 |
-
*/
|
105 |
-
protected $items = array();
|
106 |
-
|
107 |
-
|
108 |
-
public function validate() {
|
109 |
-
if(!$this->items) {
|
110 |
-
Tracker::_raiseError('Transactions need to consist of at least one item.', __METHOD__);
|
111 |
-
}
|
112 |
-
}
|
113 |
-
|
114 |
-
/**
|
115 |
-
* @link http://code.google.com/apis/analytics/docs/gaJS/gaJSApiEcommerce.html#_gat.GA_Tracker_._addItem
|
116 |
-
* @param \UnitedPrototype\GoogleAnalytics\Item $item
|
117 |
-
*/
|
118 |
-
public function addItem(Item $item) {
|
119 |
-
// Associated items inherit the transaction's order ID
|
120 |
-
$item->setOrderId($this->orderId);
|
121 |
-
|
122 |
-
$sku = $item->getSku();
|
123 |
-
$this->items[$sku] = $item;
|
124 |
-
}
|
125 |
-
|
126 |
-
/**
|
127 |
-
* @return \UnitedPrototype\GoogleAnalytics\Item[]
|
128 |
-
*/
|
129 |
-
public function getItems() {
|
130 |
-
return $this->items;
|
131 |
-
}
|
132 |
-
|
133 |
-
/**
|
134 |
-
* @return string
|
135 |
-
*/
|
136 |
-
public function getOrderId() {
|
137 |
-
return $this->orderId;
|
138 |
-
}
|
139 |
-
|
140 |
-
/**
|
141 |
-
* @param string $orderId
|
142 |
-
*/
|
143 |
-
public function setOrderId($orderId) {
|
144 |
-
$this->orderId = $orderId;
|
145 |
-
|
146 |
-
// Update order IDs of all associated items too
|
147 |
-
foreach($this->items as $item) {
|
148 |
-
$item->setOrderId($orderId);
|
149 |
-
}
|
150 |
-
}
|
151 |
-
|
152 |
-
/**
|
153 |
-
* @return string
|
154 |
-
*/
|
155 |
-
public function getAffiliation() {
|
156 |
-
return $this->affiliation;
|
157 |
-
}
|
158 |
-
|
159 |
-
/**
|
160 |
-
* @param string $affiliation
|
161 |
-
*/
|
162 |
-
public function setAffiliation($affiliation) {
|
163 |
-
$this->affiliation = $affiliation;
|
164 |
-
}
|
165 |
-
|
166 |
-
/**
|
167 |
-
* @return float
|
168 |
-
*/
|
169 |
-
public function getTotal() {
|
170 |
-
return $this->total;
|
171 |
-
}
|
172 |
-
|
173 |
-
/**
|
174 |
-
* @param float $total
|
175 |
-
*/
|
176 |
-
public function setTotal($total) {
|
177 |
-
$this->total = $total;
|
178 |
-
}
|
179 |
-
|
180 |
-
/**
|
181 |
-
* @return float
|
182 |
-
*/
|
183 |
-
public function getTax() {
|
184 |
-
return $this->tax;
|
185 |
-
}
|
186 |
-
|
187 |
-
/**
|
188 |
-
* @param float $tax
|
189 |
-
*/
|
190 |
-
public function setTax($tax) {
|
191 |
-
$this->tax = $tax;
|
192 |
-
}
|
193 |
-
|
194 |
-
/**
|
195 |
-
* @return float
|
196 |
-
*/
|
197 |
-
public function getShipping() {
|
198 |
-
return $this->shipping;
|
199 |
-
}
|
200 |
-
|
201 |
-
/**
|
202 |
-
* @param float $shipping
|
203 |
-
*/
|
204 |
-
public function setShipping($shipping) {
|
205 |
-
$this->shipping = $shipping;
|
206 |
-
}
|
207 |
-
|
208 |
-
/**
|
209 |
-
* @return string
|
210 |
-
*/
|
211 |
-
public function getCity() {
|
212 |
-
return $this->city;
|
213 |
-
}
|
214 |
-
|
215 |
-
/**
|
216 |
-
* @param string $city
|
217 |
-
*/
|
218 |
-
public function setCity($city) {
|
219 |
-
$this->city = $city;
|
220 |
-
}
|
221 |
-
|
222 |
-
/**
|
223 |
-
* @return string
|
224 |
-
*/
|
225 |
-
public function getRegion() {
|
226 |
-
return $this->region;
|
227 |
-
}
|
228 |
-
|
229 |
-
/**
|
230 |
-
* @param string $region
|
231 |
-
*/
|
232 |
-
public function setRegion($region) {
|
233 |
-
$this->region = $region;
|
234 |
-
}
|
235 |
-
|
236 |
-
/**
|
237 |
-
* @return string
|
238 |
-
*/
|
239 |
-
public function getCountry() {
|
240 |
-
return $this->country;
|
241 |
-
}
|
242 |
-
|
243 |
-
/**
|
244 |
-
* @param string $country
|
245 |
-
*/
|
246 |
-
public function setCountry($country) {
|
247 |
-
$this->country = $country;
|
248 |
-
}
|
249 |
-
|
250 |
-
}
|
251 |
-
|
252 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Sluice/Connect/lib/GoogleAnalytics/Visitor.php
DELETED
@@ -1,463 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Generic Server-Side Google Analytics PHP Client
|
5 |
-
*
|
6 |
-
* This library is free software; you can redistribute it and/or
|
7 |
-
* modify it under the terms of the GNU Lesser General Public
|
8 |
-
* License (LGPL) as published by the Free Software Foundation; either
|
9 |
-
* version 3 of the License, or (at your option) any later version.
|
10 |
-
*
|
11 |
-
* This library is distributed in the hope that it will be useful,
|
12 |
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
-
* Lesser General Public License for more details.
|
15 |
-
*
|
16 |
-
* You should have received a copy of the GNU Lesser General Public
|
17 |
-
* License along with this library; if not, write to the Free Software
|
18 |
-
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
19 |
-
*
|
20 |
-
* Google Analytics is a registered trademark of Google Inc.
|
21 |
-
*
|
22 |
-
* @link http://code.google.com/p/php-ga
|
23 |
-
*
|
24 |
-
* @license http://www.gnu.org/licenses/lgpl.html
|
25 |
-
* @author Thomas Bachem <tb@unitedprototype.com>
|
26 |
-
* @copyright Copyright (c) 2010 United Prototype GmbH (http://unitedprototype.com)
|
27 |
-
*/
|
28 |
-
|
29 |
-
namespace UnitedPrototype\GoogleAnalytics;
|
30 |
-
|
31 |
-
use UnitedPrototype\GoogleAnalytics\Internals\Util;
|
32 |
-
|
33 |
-
use DateTime;
|
34 |
-
|
35 |
-
/**
|
36 |
-
* You should serialize this object and store it in the user database to keep it
|
37 |
-
* persistent for the same user permanently (similar to the "__umta" cookie of
|
38 |
-
* the GA Javascript client).
|
39 |
-
*/
|
40 |
-
class Visitor {
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Unique user ID, will be part of the "__utma" cookie parameter
|
44 |
-
*
|
45 |
-
* @see Internals\ParameterHolder::$__utma
|
46 |
-
* @var int
|
47 |
-
*/
|
48 |
-
protected $uniqueId;
|
49 |
-
|
50 |
-
/**
|
51 |
-
* Time of the very first visit of this user, will be part of the "__utma"
|
52 |
-
* cookie parameter
|
53 |
-
*
|
54 |
-
* @see Internals\ParameterHolder::$__utma
|
55 |
-
* @var DateTime
|
56 |
-
*/
|
57 |
-
protected $firstVisitTime;
|
58 |
-
|
59 |
-
/**
|
60 |
-
* Time of the previous visit of this user, will be part of the "__utma"
|
61 |
-
* cookie parameter
|
62 |
-
*
|
63 |
-
* @see Internals\ParameterHolder::$__utma
|
64 |
-
* @see addSession
|
65 |
-
* @var DateTime
|
66 |
-
*/
|
67 |
-
protected $previousVisitTime;
|
68 |
-
|
69 |
-
/**
|
70 |
-
* Time of the current visit of this user, will be part of the "__utma"
|
71 |
-
* cookie parameter
|
72 |
-
*
|
73 |
-
* @see Internals\ParameterHolder::$__utma
|
74 |
-
* @see addSession
|
75 |
-
* @var DateTime
|
76 |
-
*/
|
77 |
-
protected $currentVisitTime;
|
78 |
-
|
79 |
-
/**
|
80 |
-
* Amount of total visits by this user, will be part of the "__utma"
|
81 |
-
* cookie parameter
|
82 |
-
*
|
83 |
-
* @see Internals\ParameterHolder::$__utma
|
84 |
-
* @var int
|
85 |
-
*/
|
86 |
-
protected $visitCount;
|
87 |
-
|
88 |
-
/**
|
89 |
-
* IP Address of the end user, e.g. "123.123.123.123", will be mapped to "utmip" parameter
|
90 |
-
* and "X-Forwarded-For" request header
|
91 |
-
*
|
92 |
-
* @see Internals\ParameterHolder::$utmip
|
93 |
-
* @see Internals\Request\HttpRequest::$xForwardedFor
|
94 |
-
* @var string
|
95 |
-
*/
|
96 |
-
protected $ipAddress;
|
97 |
-
|
98 |
-
/**
|
99 |
-
* User agent string of the end user, will be mapped to "User-Agent" request header
|
100 |
-
*
|
101 |
-
* @see Internals\Request\HttpRequest::$userAgent
|
102 |
-
* @var string
|
103 |
-
*/
|
104 |
-
protected $userAgent;
|
105 |
-
|
106 |
-
/**
|
107 |
-
* Locale string (country part optional), e.g. "de-DE", will be mapped to "utmul" parameter
|
108 |
-
*
|
109 |
-
* @see Internals\ParameterHolder::$utmul
|
110 |
-
* @var string
|
111 |
-
*/
|
112 |
-
protected $locale;
|
113 |
-
|
114 |
-
/**
|
115 |
-
* Visitor's Flash version, e.g. "9.0 r28", will be maped to "utmfl" parameter
|
116 |
-
*
|
117 |
-
* @see Internals\ParameterHolder::$utmfl
|
118 |
-
* @var string
|
119 |
-
*/
|
120 |
-
protected $flashVersion;
|
121 |
-
|
122 |
-
/**
|
123 |
-
* Visitor's Java support, will be mapped to "utmje" parameter
|
124 |
-
*
|
125 |
-
* @see Internals\ParameterHolder::$utmje
|
126 |
-
* @var bool
|
127 |
-
*/
|
128 |
-
protected $javaEnabled;
|
129 |
-
|
130 |
-
/**
|
131 |
-
* Visitor's screen color depth, e.g. 32, will be mapped to "utmsc" parameter
|
132 |
-
*
|
133 |
-
* @see Internals\ParameterHolder::$utmsc
|
134 |
-
* @var string
|
135 |
-
*/
|
136 |
-
protected $screenColorDepth;
|
137 |
-
|
138 |
-
/**
|
139 |
-
* Visitor's screen resolution, e.g. "1024x768", will be mapped to "utmsr" parameter
|
140 |
-
*
|
141 |
-
* @see Internals\ParameterHolder::$utmsr
|
142 |
-
* @var string
|
143 |
-
*/
|
144 |
-
protected $screenResolution;
|
145 |
-
|
146 |
-
|
147 |
-
/**
|
148 |
-
* Creates a new visitor without any previous visit information.
|
149 |
-
*/
|
150 |
-
public function __construct() {
|
151 |
-
// ga.js sets all three timestamps to now for new visitors, so we do the same
|
152 |
-
$now = new DateTime();
|
153 |
-
$this->setFirstVisitTime($now);
|
154 |
-
$this->setPreviousVisitTime($now);
|
155 |
-
$this->setCurrentVisitTime($now);
|
156 |
-
|
157 |
-
$this->setVisitCount(1);
|
158 |
-
}
|
159 |
-
|
160 |
-
/**
|
161 |
-
* Will extract information for the "uniqueId", "firstVisitTime", "previousVisitTime",
|
162 |
-
* "currentVisitTime" and "visitCount" properties from the given "__utma" cookie
|
163 |
-
* value.
|
164 |
-
*
|
165 |
-
* @see Internals\ParameterHolder::$__utma
|
166 |
-
* @see Internals\Request\Request::buildCookieParameters()
|
167 |
-
* @param string $value
|
168 |
-
* @return $this
|
169 |
-
*/
|
170 |
-
public function fromUtma($value) {
|
171 |
-
$parts = explode('.', $value);
|
172 |
-
if(count($parts) != 6) {
|
173 |
-
Tracker::_raiseError('The given "__utma" cookie value is invalid.', __METHOD__);
|
174 |
-
return $this;
|
175 |
-
}
|
176 |
-
|
177 |
-
$this->setUniqueId($parts[1]);
|
178 |
-
$this->setFirstVisitTime(new DateTime('@' . $parts[2]));
|
179 |
-
$this->setPreviousVisitTime(new DateTime('@' . $parts[3]));
|
180 |
-
$this->setCurrentVisitTime(new DateTime('@' . $parts[4]));
|
181 |
-
$this->setVisitCount($parts[5]);
|
182 |
-
|
183 |
-
// Allow chaining
|
184 |
-
return $this;
|
185 |
-
}
|
186 |
-
|
187 |
-
/**
|
188 |
-
* Will extract information for the "ipAddress", "userAgent" and "locale" properties
|
189 |
-
* from the given $_SERVER variable.
|
190 |
-
*
|
191 |
-
* @param array $value
|
192 |
-
* @return $this
|
193 |
-
*/
|
194 |
-
public function fromServerVar(array $value) {
|
195 |
-
if(!empty($value['REMOTE_ADDR'])) {
|
196 |
-
$ip = null;
|
197 |
-
foreach(array('X_FORWARDED_FOR', 'REMOTE_ADDR') as $key) {
|
198 |
-
if(!empty($value[$key]) && !$ip) {
|
199 |
-
$ips = explode(',', $value[$key]);
|
200 |
-
$ip = trim($ips[(count($ips) - 1)]);
|
201 |
-
|
202 |
-
// Double-check if the address has a valid format
|
203 |
-
if(!preg_match('/^[\d+]{1,3}\.[\d+]{1,3}\.[\d+]{1,3}\.[\d+]{1,3}$/i', $ip)) {
|
204 |
-
$ip = null;
|
205 |
-
}
|
206 |
-
// Exclude private IP address ranges
|
207 |
-
if(preg_match('#^(?:127\.0\.0\.1|10\.|192\.168\.|172\.(?:1[6-9]|2[0-9]|3[0-1])\.)#', $ip)) {
|
208 |
-
$ip = null;
|
209 |
-
}
|
210 |
-
}
|
211 |
-
}
|
212 |
-
|
213 |
-
if($ip) {
|
214 |
-
$this->setIpAddress($ip);
|
215 |
-
}
|
216 |
-
}
|
217 |
-
|
218 |
-
if(!empty($value['HTTP_USER_AGENT'])) {
|
219 |
-
$this->setUserAgent($value['HTTP_USER_AGENT']);
|
220 |
-
}
|
221 |
-
|
222 |
-
if(!empty($value['HTTP_ACCEPT_LANGUAGE'])) {
|
223 |
-
$parsedLocales = array();
|
224 |
-
if(preg_match_all('/(^|\s*,\s*)([a-zA-Z]{1,8}(-[a-zA-Z]{1,8})*)\s*(;\s*q\s*=\s*(1(\.0{0,3})?|0(\.[0-9]{0,3})))?/i', $value['HTTP_ACCEPT_LANGUAGE'], $matches)) {
|
225 |
-
$matches[2] = array_map(function($part) { return str_replace('-', '_', $part); }, $matches[2]);
|
226 |
-
$matches[5] = array_map(function($part) { return $part === '' ? 1 : $part; }, $matches[5]);
|
227 |
-
$parsedLocales = array_combine($matches[2], $matches[5]);
|
228 |
-
arsort($parsedLocales, SORT_NUMERIC);
|
229 |
-
$parsedLocales = array_keys($parsedLocales);
|
230 |
-
}
|
231 |
-
|
232 |
-
if($parsedLocales) {
|
233 |
-
$this->setLocale($parsedLocales[0]);
|
234 |
-
}
|
235 |
-
}
|
236 |
-
|
237 |
-
// Allow chaining
|
238 |
-
return $this;
|
239 |
-
}
|
240 |
-
|
241 |
-
/**
|
242 |
-
* Generates a hashed value from user-specific properties.
|
243 |
-
*
|
244 |
-
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/v4/Tracker.as#542
|
245 |
-
* @return int
|
246 |
-
*/
|
247 |
-
protected function generateHash() {
|
248 |
-
// TODO: Emulate orginal Google Analytics client library generation more closely
|
249 |
-
$string = $this->userAgent;
|
250 |
-
$string .= $this->screenResolution . $this->screenColorDepth;
|
251 |
-
return Util::generateHash($string);
|
252 |
-
}
|
253 |
-
|
254 |
-
/**
|
255 |
-
* Generates a unique user ID from the current user-specific properties.
|
256 |
-
*
|
257 |
-
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/v4/Tracker.as#563
|
258 |
-
* @return int
|
259 |
-
*/
|
260 |
-
protected function generateUniqueId() {
|
261 |
-
// There seems to be an error in the gaforflash code, so we take the formula
|
262 |
-
// from http://xahlee.org/js/google_analytics_tracker_2010-07-01_expanded.js line 711
|
263 |
-
// instead ("&" instead of "*")
|
264 |
-
return ((Util::generate32bitRandom() ^ $this->generateHash()) & 0x7fffffff);
|
265 |
-
}
|
266 |
-
|
267 |
-
/**
|
268 |
-
* @see generateUniqueId
|
269 |
-
* @param int $value
|
270 |
-
*/
|
271 |
-
public function setUniqueId($value) {
|
272 |
-
if($value < 0 || $value > 0x7fffffff) {
|
273 |
-
Tracker::_raiseError('Visitor unique ID has to be a 32-bit integer between 0 and ' . 0x7fffffff . '.', __METHOD__);
|
274 |
-
}
|
275 |
-
|
276 |
-
$this->uniqueId = (int)$value;
|
277 |
-
}
|
278 |
-
|
279 |
-
/**
|
280 |
-
* Will be generated on first call (if not set already) to include as much
|
281 |
-
* user-specific information as possible.
|
282 |
-
*
|
283 |
-
* @return int
|
284 |
-
*/
|
285 |
-
public function getUniqueId() {
|
286 |
-
if($this->uniqueId === null) {
|
287 |
-
$this->uniqueId = $this->generateUniqueId();
|
288 |
-
}
|
289 |
-
return $this->uniqueId;
|
290 |
-
}
|
291 |
-
|
292 |
-
/**
|
293 |
-
* Updates the "previousVisitTime", "currentVisitTime" and "visitCount"
|
294 |
-
* fields based on the given session object.
|
295 |
-
*
|
296 |
-
* @param Session $session
|
297 |
-
*/
|
298 |
-
public function addSession(Session $session) {
|
299 |
-
$startTime = $session->getStartTime();
|
300 |
-
if($startTime != $this->currentVisitTime) {
|
301 |
-
$this->previousVisitTime = $this->currentVisitTime;
|
302 |
-
$this->currentVisitTime = $startTime;
|
303 |
-
++$this->visitCount;
|
304 |
-
}
|
305 |
-
}
|
306 |
-
|
307 |
-
/**
|
308 |
-
* @param DateTime $value
|
309 |
-
*/
|
310 |
-
public function setFirstVisitTime(DateTime $value) {
|
311 |
-
$this->firstVisitTime = $value;
|
312 |
-
}
|
313 |
-
|
314 |
-
/**
|
315 |
-
* @return DateTime
|
316 |
-
*/
|
317 |
-
public function getFirstVisitTime() {
|
318 |
-
return $this->firstVisitTime;
|
319 |
-
}
|
320 |
-
|
321 |
-
/**
|
322 |
-
* @param DateTime $value
|
323 |
-
*/
|
324 |
-
public function setPreviousVisitTime(DateTime $value) {
|
325 |
-
$this->previousVisitTime = $value;
|
326 |
-
}
|
327 |
-
|
328 |
-
/**
|
329 |
-
* @return DateTime
|
330 |
-
*/
|
331 |
-
public function getPreviousVisitTime() {
|
332 |
-
return $this->previousVisitTime;
|
333 |
-
}
|
334 |
-
|
335 |
-
/**
|
336 |
-
* @param DateTime $value
|
337 |
-
*/
|
338 |
-
public function setCurrentVisitTime(DateTime $value) {
|
339 |
-
$this->currentVisitTime = $value;
|
340 |
-
}
|
341 |
-
|
342 |
-
/**
|
343 |
-
* @return DateTime
|
344 |
-
*/
|
345 |
-
public function getCurrentVisitTime() {
|
346 |
-
return $this->currentVisitTime;
|
347 |
-
}
|
348 |
-
|
349 |
-
/**
|
350 |
-
* @param int $value
|
351 |
-
*/
|
352 |
-
public function setVisitCount($value) {
|
353 |
-
$this->visitCount = (int)$value;
|
354 |
-
}
|
355 |
-
|
356 |
-
/**
|
357 |
-
* @return int
|
358 |
-
*/
|
359 |
-
public function getVisitCount() {
|
360 |
-
return $this->visitCount;
|
361 |
-
}
|
362 |
-
|
363 |
-
/**
|
364 |
-
* @param string $value
|
365 |
-
*/
|
366 |
-
public function setIpAddress($value) {
|
367 |
-
$this->ipAddress = $value;
|
368 |
-
}
|
369 |
-
|
370 |
-
/**
|
371 |
-
* @return string
|
372 |
-
*/
|
373 |
-
public function getIpAddress() {
|
374 |
-
return $this->ipAddress;
|
375 |
-
}
|
376 |
-
|
377 |
-
/**
|
378 |
-
* @param string $value
|
379 |
-
*/
|
380 |
-
public function setUserAgent($value) {
|
381 |
-
$this->userAgent = $value;
|
382 |
-
}
|
383 |
-
|
384 |
-
/**
|
385 |
-
* @return string
|
386 |
-
*/
|
387 |
-
public function getUserAgent() {
|
388 |
-
return $this->userAgent;
|
389 |
-
}
|
390 |
-
|
391 |
-
/**
|
392 |
-
* @param string $value
|
393 |
-
*/
|
394 |
-
public function setLocale($value) {
|
395 |
-
$this->locale = $value;
|
396 |
-
}
|
397 |
-
|
398 |
-
/**
|
399 |
-
* @return string
|
400 |
-
*/
|
401 |
-
public function getLocale() {
|
402 |
-
return $this->locale;
|
403 |
-
}
|
404 |
-
|
405 |
-
/**
|
406 |
-
* @param string $value
|
407 |
-
*/
|
408 |
-
public function setFlashVersion($value) {
|
409 |
-
$this->flashVersion = $value;
|
410 |
-
}
|
411 |
-
|
412 |
-
/**
|
413 |
-
* @return string
|
414 |
-
*/
|
415 |
-
public function getFlashVersion() {
|
416 |
-
return $this->flashVersion;
|
417 |
-
}
|
418 |
-
|
419 |
-
/**
|
420 |
-
* @param bool $value
|
421 |
-
*/
|
422 |
-
public function setJavaEnabled($value) {
|
423 |
-
$this->javaEnabled = (bool)$value;
|
424 |
-
}
|
425 |
-
|
426 |
-
/**
|
427 |
-
* @return bool
|
428 |
-
*/
|
429 |
-
public function getJavaEnabled() {
|
430 |
-
return $this->javaEnabled;
|
431 |
-
}
|
432 |
-
|
433 |
-
/**
|
434 |
-
* @param int $value
|
435 |
-
*/
|
436 |
-
public function setScreenColorDepth($value) {
|
437 |
-
$this->screenColorDepth = (int)$value;
|
438 |
-
}
|
439 |
-
|
440 |
-
/**
|
441 |
-
* @return string
|
442 |
-
*/
|
443 |
-
public function getScreenColorDepth() {
|
444 |
-
return $this->screenColorDepth;
|
445 |
-
}
|
446 |
-
|
447 |
-
/**
|
448 |
-
* @param string $value
|
449 |
-
*/
|
450 |
-
public function setScreenResolution($value) {
|
451 |
-
$this->screenResolution = $value;
|
452 |
-
}
|
453 |
-
|
454 |
-
/**
|
455 |
-
* @return string
|
456 |
-
*/
|
457 |
-
public function getScreenResolution() {
|
458 |
-
return $this->screenResolution;
|
459 |
-
}
|
460 |
-
|
461 |
-
}
|
462 |
-
|
463 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/etc/modules/Sluice_Connect.xml
DELETED
@@ -1,9 +0,0 @@
|
|
1 |
-
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
-
<config>
|
3 |
-
<modules>
|
4 |
-
<Sluice_Connect>
|
5 |
-
<active>true</active>
|
6 |
-
<codePool>local</codePool>
|
7 |
-
</Sluice_Connect>
|
8 |
-
</modules>
|
9 |
-
</config>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/GA-client/GA-client.php
ADDED
@@ -0,0 +1,4887 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Generic Server-Side Google Analytics PHP Client
|
5 |
+
*
|
6 |
+
* This library is free software; you can redistribute it and/or
|
7 |
+
* modify it under the terms of the GNU Lesser General Public
|
8 |
+
* License (LGPL) as published by the Free Software Foundation; either
|
9 |
+
* version 3 of the License, or (at your option) any later version.
|
10 |
+
*
|
11 |
+
* This library is distributed in the hope that it will be useful,
|
12 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
+
* Lesser General Public License for more details.
|
15 |
+
*
|
16 |
+
* You should have received a copy of the GNU Lesser General Public
|
17 |
+
* License along with this library; if not, write to the Free Software
|
18 |
+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
19 |
+
*
|
20 |
+
* Google Analytics is a registered trademark of Google Inc.
|
21 |
+
*
|
22 |
+
* @link http://code.google.com/p/php-ga
|
23 |
+
*
|
24 |
+
* @license http://www.gnu.org/licenses/lgpl.html
|
25 |
+
* @author Thomas Bachem <tb@unitedprototype.com>
|
26 |
+
* @copyright Copyright (c) 2010 United Prototype GmbH (http://unitedprototype.com)
|
27 |
+
*/
|
28 |
+
|
29 |
+
namespace UnitedPrototype\GoogleAnalytics{
|
30 |
+
|
31 |
+
use UnitedPrototype\GoogleAnalytics\Internals\Util;
|
32 |
+
|
33 |
+
use DateTime;
|
34 |
+
|
35 |
+
/**
|
36 |
+
* You should serialize this object and store it in e.g. the user database to keep it
|
37 |
+
* persistent for the same user permanently (similar to the "__umtz" cookie of
|
38 |
+
* the GA Javascript client).
|
39 |
+
*/
|
40 |
+
class Campaign {
|
41 |
+
|
42 |
+
/**
|
43 |
+
* See self::TYPE_* constants, will be mapped to "__utmz" parameter.
|
44 |
+
*
|
45 |
+
* @see Internals\ParameterHolder::$__utmz
|
46 |
+
* @var string
|
47 |
+
*/
|
48 |
+
protected $type;
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Time of the creation of this campaign, will be mapped to "__utmz" parameter.
|
52 |
+
*
|
53 |
+
* @see Internals\ParameterHolder::$__utmz
|
54 |
+
* @var DateTime
|
55 |
+
*/
|
56 |
+
protected $creationTime;
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Response Count, will be mapped to "__utmz" parameter.
|
60 |
+
*
|
61 |
+
* Is also used to determine whether the campaign is new or repeated,
|
62 |
+
* which will be mapped to "utmcn" and "utmcr" parameters.
|
63 |
+
*
|
64 |
+
* @see Internals\ParameterHolder::$__utmz
|
65 |
+
* @see Internals\ParameterHolder::$utmcn
|
66 |
+
* @see Internals\ParameterHolder::$utmcr
|
67 |
+
* @var int
|
68 |
+
*/
|
69 |
+
protected $responseCount = 0;
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Campaign ID, a.k.a. "utm_id" query parameter for ga.js
|
73 |
+
* Will be mapped to "__utmz" parameter.
|
74 |
+
*
|
75 |
+
* @see Internals\ParameterHolder::$__utmz
|
76 |
+
* @var int
|
77 |
+
*/
|
78 |
+
protected $id;
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Source, a.k.a. "utm_source" query parameter for ga.js.
|
82 |
+
* Will be mapped to "utmcsr" key in "__utmz" parameter.
|
83 |
+
*
|
84 |
+
* @see Internals\ParameterHolder::$__utmz
|
85 |
+
* @var string
|
86 |
+
*/
|
87 |
+
protected $source;
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Google AdWords Click ID, a.k.a. "gclid" query parameter for ga.js.
|
91 |
+
* Will be mapped to "utmgclid" key in "__utmz" parameter.
|
92 |
+
*
|
93 |
+
* @see Internals\ParameterHolder::$__utmz
|
94 |
+
* @var string
|
95 |
+
*/
|
96 |
+
protected $gClickId;
|
97 |
+
|
98 |
+
/**
|
99 |
+
* DoubleClick (?) Click ID. Will be mapped to "utmdclid" key in "__utmz" parameter.
|
100 |
+
*
|
101 |
+
* @see Internals\ParameterHolder::$__utmz
|
102 |
+
* @var string
|
103 |
+
*/
|
104 |
+
protected $dClickId;
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Name, a.k.a. "utm_campaign" query parameter for ga.js.
|
108 |
+
* Will be mapped to "utmccn" key in "__utmz" parameter.
|
109 |
+
*
|
110 |
+
* @see Internals\ParameterHolder::$__utmz
|
111 |
+
* @var string
|
112 |
+
*/
|
113 |
+
protected $name;
|
114 |
+
|
115 |
+
/**
|
116 |
+
* Medium, a.k.a. "utm_medium" query parameter for ga.js.
|
117 |
+
* Will be mapped to "utmcmd" key in "__utmz" parameter.
|
118 |
+
*
|
119 |
+
* @see Internals\ParameterHolder::$__utmz
|
120 |
+
* @var string
|
121 |
+
*/
|
122 |
+
protected $medium;
|
123 |
+
|
124 |
+
/**
|
125 |
+
* Terms/Keywords, a.k.a. "utm_term" query parameter for ga.js.
|
126 |
+
* Will be mapped to "utmctr" key in "__utmz" parameter.
|
127 |
+
*
|
128 |
+
* @see Internals\ParameterHolder::$__utmz
|
129 |
+
* @var string
|
130 |
+
*/
|
131 |
+
protected $term;
|
132 |
+
|
133 |
+
/**
|
134 |
+
* Ad Content Description, a.k.a. "utm_content" query parameter for ga.js.
|
135 |
+
* Will be mapped to "utmcct" key in "__utmz" parameter.
|
136 |
+
*
|
137 |
+
* @see Internals\ParameterHolder::$__utmz
|
138 |
+
* @var string
|
139 |
+
*/
|
140 |
+
protected $content;
|
141 |
+
|
142 |
+
|
143 |
+
/**
|
144 |
+
* @const string
|
145 |
+
*/
|
146 |
+
const TYPE_DIRECT = 'direct';
|
147 |
+
/**
|
148 |
+
* @const string
|
149 |
+
*/
|
150 |
+
const TYPE_ORGANIC = 'organic';
|
151 |
+
/**
|
152 |
+
* @const string
|
153 |
+
*/
|
154 |
+
const TYPE_REFERRAL = 'referral';
|
155 |
+
|
156 |
+
|
157 |
+
/**
|
158 |
+
* @see createFromReferrer
|
159 |
+
* @param string $type See TYPE_* constants
|
160 |
+
*/
|
161 |
+
public function __construct($type) {
|
162 |
+
if(!in_array($type, array(self::TYPE_DIRECT, self::TYPE_ORGANIC, self::TYPE_REFERRAL))) {
|
163 |
+
Tracker::_raiseError('Campaign type has to be one of the Campaign::TYPE_* constant values.', __METHOD__);
|
164 |
+
}
|
165 |
+
|
166 |
+
$this->type = $type;
|
167 |
+
|
168 |
+
switch($type) {
|
169 |
+
// See http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/campaign/CampaignManager.as#375
|
170 |
+
case self::TYPE_DIRECT:
|
171 |
+
$this->name = '(direct)';
|
172 |
+
$this->source = '(direct)';
|
173 |
+
$this->medium = '(none)';
|
174 |
+
break;
|
175 |
+
// See http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/campaign/CampaignManager.as#340
|
176 |
+
case self::TYPE_REFERRAL:
|
177 |
+
$this->name = '(referral)';
|
178 |
+
$this->medium = 'referral';
|
179 |
+
break;
|
180 |
+
// See http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/campaign/CampaignManager.as#280
|
181 |
+
case self::TYPE_ORGANIC:
|
182 |
+
$this->name = '(organic)';
|
183 |
+
$this->medium = 'organic';
|
184 |
+
break;
|
185 |
+
}
|
186 |
+
|
187 |
+
$this->creationTime = new DateTime();
|
188 |
+
}
|
189 |
+
|
190 |
+
/**
|
191 |
+
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/campaign/CampaignManager.as#333
|
192 |
+
* @param string $url
|
193 |
+
* @return \UnitedPrototype\GoogleAnalytics\Campaign
|
194 |
+
*/
|
195 |
+
public static function createFromReferrer($url) {
|
196 |
+
$instance = new static(self::TYPE_REFERRAL);
|
197 |
+
$urlInfo = parse_url($url);
|
198 |
+
$instance->source = $urlInfo['host'];
|
199 |
+
$instance->content = $urlInfo['path'];
|
200 |
+
|
201 |
+
return $instance;
|
202 |
+
}
|
203 |
+
|
204 |
+
/**
|
205 |
+
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/campaign/CampaignTracker.as#153
|
206 |
+
*/
|
207 |
+
public function validate() {
|
208 |
+
// NOTE: gaforflash states that id and gClickId must also be specified,
|
209 |
+
// but that doesn't seem to be correct
|
210 |
+
if(!$this->source) {
|
211 |
+
Tracker::_raiseError('Campaigns need to have at least the "source" attribute defined.', __METHOD__);
|
212 |
+
}
|
213 |
+
}
|
214 |
+
|
215 |
+
/**
|
216 |
+
* @param string $type
|
217 |
+
*/
|
218 |
+
public function setType($type) {
|
219 |
+
$this->type = $type;
|
220 |
+
}
|
221 |
+
|
222 |
+
/**
|
223 |
+
* @return string
|
224 |
+
*/
|
225 |
+
public function getType() {
|
226 |
+
return $this->type;
|
227 |
+
}
|
228 |
+
|
229 |
+
/**
|
230 |
+
* @param DateTime $creationTime
|
231 |
+
*/
|
232 |
+
public function setCreationTime(DateTime $creationTime) {
|
233 |
+
$this->creationTime = $creationTime;
|
234 |
+
}
|
235 |
+
|
236 |
+
/**
|
237 |
+
* @return DateTime
|
238 |
+
*/
|
239 |
+
public function getCreationTime() {
|
240 |
+
return $this->creationTime;
|
241 |
+
}
|
242 |
+
|
243 |
+
/**
|
244 |
+
* @param int $esponseCount
|
245 |
+
*/
|
246 |
+
public function setResponseCount($responseCount) {
|
247 |
+
$this->responseCount = (int)$responseCount;
|
248 |
+
}
|
249 |
+
|
250 |
+
/**
|
251 |
+
* @return int
|
252 |
+
*/
|
253 |
+
public function getResponseCount() {
|
254 |
+
return $this->responseCount;
|
255 |
+
}
|
256 |
+
|
257 |
+
/**
|
258 |
+
* @param int $byAmount
|
259 |
+
*/
|
260 |
+
public function increaseResponseCount($byAmount = 1) {
|
261 |
+
$this->responseCount += $byAmount;
|
262 |
+
}
|
263 |
+
|
264 |
+
/**
|
265 |
+
* @param int $id
|
266 |
+
*/
|
267 |
+
public function setId($id) {
|
268 |
+
$this->id = $id;
|
269 |
+
}
|
270 |
+
|
271 |
+
/**
|
272 |
+
* @return int
|
273 |
+
*/
|
274 |
+
public function getId() {
|
275 |
+
return $this->id;
|
276 |
+
}
|
277 |
+
|
278 |
+
/**
|
279 |
+
* @param string $source
|
280 |
+
*/
|
281 |
+
public function setSource($source) {
|
282 |
+
$this->source = $source;
|
283 |
+
}
|
284 |
+
|
285 |
+
/**
|
286 |
+
* @return string
|
287 |
+
*/
|
288 |
+
public function getSource() {
|
289 |
+
return $this->source;
|
290 |
+
}
|
291 |
+
|
292 |
+
/**
|
293 |
+
* @param string $gClickId
|
294 |
+
*/
|
295 |
+
public function setGClickId($gClickId) {
|
296 |
+
$this->gClickId = $gClickId;
|
297 |
+
}
|
298 |
+
|
299 |
+
/**
|
300 |
+
* @return string
|
301 |
+
*/
|
302 |
+
public function getGClickId() {
|
303 |
+
return $this->gClickId;
|
304 |
+
}
|
305 |
+
|
306 |
+
/**
|
307 |
+
* @param string $dClickId
|
308 |
+
*/
|
309 |
+
public function setDClickId($dClickId) {
|
310 |
+
$this->dClickId = $dClickId;
|
311 |
+
}
|
312 |
+
|
313 |
+
/**
|
314 |
+
* @return string
|
315 |
+
*/
|
316 |
+
public function getDClickId() {
|
317 |
+
return $this->dClickId;
|
318 |
+
}
|
319 |
+
|
320 |
+
/**
|
321 |
+
* @param string $name
|
322 |
+
*/
|
323 |
+
public function setName($name) {
|
324 |
+
$this->name = $name;
|
325 |
+
}
|
326 |
+
|
327 |
+
/**
|
328 |
+
* @return string
|
329 |
+
*/
|
330 |
+
public function getName() {
|
331 |
+
return $this->name;
|
332 |
+
}
|
333 |
+
|
334 |
+
/**
|
335 |
+
* @param string $medium
|
336 |
+
*/
|
337 |
+
public function setMedium($medium) {
|
338 |
+
$this->medium = $medium;
|
339 |
+
}
|
340 |
+
|
341 |
+
/**
|
342 |
+
* @return string
|
343 |
+
*/
|
344 |
+
public function getMedium() {
|
345 |
+
return $this->medium;
|
346 |
+
}
|
347 |
+
|
348 |
+
/**
|
349 |
+
* @param string $term
|
350 |
+
*/
|
351 |
+
public function setTerm($term) {
|
352 |
+
$this->term = $term;
|
353 |
+
}
|
354 |
+
|
355 |
+
/**
|
356 |
+
* @return string
|
357 |
+
*/
|
358 |
+
public function getTerm() {
|
359 |
+
return $this->term;
|
360 |
+
}
|
361 |
+
|
362 |
+
/**
|
363 |
+
* @param string $content
|
364 |
+
*/
|
365 |
+
public function setContent($content) {
|
366 |
+
$this->content = $content;
|
367 |
+
}
|
368 |
+
|
369 |
+
/**
|
370 |
+
* @return string
|
371 |
+
*/
|
372 |
+
public function getContent() {
|
373 |
+
return $this->content;
|
374 |
+
}
|
375 |
+
|
376 |
+
}
|
377 |
+
|
378 |
+
}
|
379 |
+
|
380 |
+
|
381 |
+
|
382 |
+
|
383 |
+
|
384 |
+
/**
|
385 |
+
* Generic Server-Side Google Analytics PHP Client
|
386 |
+
*
|
387 |
+
* This library is free software; you can redistribute it and/or
|
388 |
+
* modify it under the terms of the GNU Lesser General Public
|
389 |
+
* License (LGPL) as published by the Free Software Foundation; either
|
390 |
+
* version 3 of the License, or (at your option) any later version.
|
391 |
+
*
|
392 |
+
* This library is distributed in the hope that it will be useful,
|
393 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
394 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
395 |
+
* Lesser General Public License for more details.
|
396 |
+
*
|
397 |
+
* You should have received a copy of the GNU Lesser General Public
|
398 |
+
* License along with this library; if not, write to the Free Software
|
399 |
+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
400 |
+
*
|
401 |
+
* Google Analytics is a registered trademark of Google Inc.
|
402 |
+
*
|
403 |
+
* @link http://code.google.com/p/php-ga
|
404 |
+
*
|
405 |
+
* @license http://www.gnu.org/licenses/lgpl.html
|
406 |
+
* @author Thomas Bachem <tb@unitedprototype.com>
|
407 |
+
* @copyright Copyright (c) 2010 United Prototype GmbH (http://unitedprototype.com)
|
408 |
+
*/
|
409 |
+
|
410 |
+
namespace UnitedPrototype\GoogleAnalytics{
|
411 |
+
|
412 |
+
/**
|
413 |
+
* Note: Doesn't necessarily have to be consistent across requests, as it doesn't
|
414 |
+
* alter the actual tracking result.
|
415 |
+
*
|
416 |
+
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/core/GIFRequest.as
|
417 |
+
*/
|
418 |
+
class Config {
|
419 |
+
|
420 |
+
/**
|
421 |
+
* How strict should errors get handled? After all, we do just do some
|
422 |
+
* tracking stuff here, and errors shouldn't break an application's
|
423 |
+
* functionality in production.
|
424 |
+
* RECOMMENDATION: Exceptions during deveopment, warnings in production.
|
425 |
+
*
|
426 |
+
* Assign any value of the self::ERROR_SEVERITY_* constants.
|
427 |
+
*
|
428 |
+
* @see Tracker::_raiseError()
|
429 |
+
* @var int
|
430 |
+
*/
|
431 |
+
protected $errorSeverity = self::ERROR_SEVERITY_EXCEPTIONS;
|
432 |
+
|
433 |
+
/**
|
434 |
+
* Ignore all errors completely.
|
435 |
+
*/
|
436 |
+
const ERROR_SEVERITY_SILENCE = 0;
|
437 |
+
/**
|
438 |
+
* Trigger PHP errors with a E_USER_WARNING error level.
|
439 |
+
*/
|
440 |
+
const ERROR_SEVERITY_WARNINGS = 1;
|
441 |
+
/**
|
442 |
+
* Throw UnitedPrototype\GoogleAnalytics\Exception exceptions.
|
443 |
+
*/
|
444 |
+
const ERROR_SEVERITY_EXCEPTIONS = 2;
|
445 |
+
|
446 |
+
/**
|
447 |
+
* Whether to just queue all requests on HttpRequest::fire() and actually send
|
448 |
+
* them on PHP script shutdown after all other tasks are done.
|
449 |
+
*
|
450 |
+
* This has two advantages:
|
451 |
+
* 1) It effectively doesn't affect app performance
|
452 |
+
* 2) It can e.g. handle custom variables that were set after scheduling a request
|
453 |
+
*
|
454 |
+
* @see Internals\Request\HttpRequest::fire()
|
455 |
+
* @var bool
|
456 |
+
*/
|
457 |
+
protected $sendOnShutdown = false;
|
458 |
+
|
459 |
+
/**
|
460 |
+
* Whether to make asynchronous requests to GA without waiting for any
|
461 |
+
* response (speeds up doing requests).
|
462 |
+
*
|
463 |
+
* @see Internals\Request\HttpRequest::send()
|
464 |
+
* @var bool
|
465 |
+
*/
|
466 |
+
protected $fireAndForget = false;
|
467 |
+
|
468 |
+
/**
|
469 |
+
* Logging callback, registered via setLoggingCallback(). Will be fired
|
470 |
+
* whenever a request gets sent out and receives the full HTTP request
|
471 |
+
* as the first and the full HTTP response (or null if the "fireAndForget"
|
472 |
+
* option or simulation mode are used) as the second argument.
|
473 |
+
*
|
474 |
+
* @var \Closure
|
475 |
+
*/
|
476 |
+
protected $loggingCallback;
|
477 |
+
|
478 |
+
/**
|
479 |
+
* Seconds (float allowed) to wait until timeout when connecting to the
|
480 |
+
* Google analytics endpoint host
|
481 |
+
*
|
482 |
+
* @see Internals\Request\HttpRequest::send()
|
483 |
+
* @var float
|
484 |
+
*/
|
485 |
+
protected $requestTimeout = 1;
|
486 |
+
|
487 |
+
// FIXME: Add SSL support, https://ssl.google-analytics.com
|
488 |
+
|
489 |
+
/**
|
490 |
+
* Google Analytics tracking request endpoint host. Can be set to null to
|
491 |
+
* silently simulate (and log) requests without actually sending them.
|
492 |
+
*
|
493 |
+
* @see Internals\Request\HttpRequest::send()
|
494 |
+
* @var string
|
495 |
+
*/
|
496 |
+
protected $endPointHost = 'www.google-analytics.com';
|
497 |
+
|
498 |
+
/**
|
499 |
+
* Google Analytics tracking request endpoint path
|
500 |
+
*
|
501 |
+
* @see Internals\Request\HttpRequest::send()
|
502 |
+
* @var string
|
503 |
+
*/
|
504 |
+
protected $endPointPath = '/__utm.gif';
|
505 |
+
|
506 |
+
/**
|
507 |
+
* Whether to anonymize IP addresses within Google Analytics by stripping
|
508 |
+
* the last IP address block, will be mapped to "aip" parameter
|
509 |
+
*
|
510 |
+
* @see Internals\ParameterHolder::$aip
|
511 |
+
* @link http://code.google.com/apis/analytics/docs/gaJS/gaJSApi_gat.html#_gat._anonymizeIp
|
512 |
+
* @var bool
|
513 |
+
*/
|
514 |
+
protected $anonymizeIpAddresses = false;
|
515 |
+
|
516 |
+
/**
|
517 |
+
* Defines a new sample set size (0-100) for Site Speed data collection.
|
518 |
+
* By default, a fixed 1% sampling of your site visitors make up the data pool from which
|
519 |
+
* the Site Speed metrics are derived.
|
520 |
+
*
|
521 |
+
* @see Page::$loadTime
|
522 |
+
* @link http://code.google.com/apis/analytics/docs/gaJS/gaJSApiBasicConfiguration.html#_gat.GA_Tracker_._setSiteSpeedSampleRate
|
523 |
+
* @var int
|
524 |
+
*/
|
525 |
+
protected $sitespeedSampleRate = 1;
|
526 |
+
|
527 |
+
|
528 |
+
/**
|
529 |
+
* @param array $properties
|
530 |
+
*/
|
531 |
+
public function __construct(array $properties = array()) {
|
532 |
+
foreach($properties as $property => $value) {
|
533 |
+
// PHP doesn't care about case in method names
|
534 |
+
$setterMethod = 'set' . $property;
|
535 |
+
|
536 |
+
if(method_exists($this, $setterMethod)) {
|
537 |
+
$this->$setterMethod($value);
|
538 |
+
} else {
|
539 |
+
return Tracker::_raiseError('There is no setting "' . $property . '".', __METHOD__);
|
540 |
+
}
|
541 |
+
}
|
542 |
+
}
|
543 |
+
|
544 |
+
/**
|
545 |
+
* @return int See self::ERROR_SEVERITY_* constants
|
546 |
+
*/
|
547 |
+
public function getErrorSeverity() {
|
548 |
+
return $this->errorSeverity;
|
549 |
+
}
|
550 |
+
|
551 |
+
/**
|
552 |
+
* @param int $errorSeverity See self::ERROR_SEVERITY_* constants
|
553 |
+
*/
|
554 |
+
public function setErrorSeverity($errorSeverity) {
|
555 |
+
$this->errorSeverity = $errorSeverity;
|
556 |
+
}
|
557 |
+
|
558 |
+
/**
|
559 |
+
* @return bool
|
560 |
+
*/
|
561 |
+
public function getSendOnShutdown() {
|
562 |
+
return $this->sendOnShutdown;
|
563 |
+
}
|
564 |
+
|
565 |
+
/**
|
566 |
+
* @param bool $sendOnShutdown
|
567 |
+
*/
|
568 |
+
public function setSendOnShutdown($sendOnShutdown) {
|
569 |
+
$this->sendOnShutdown = $sendOnShutdown;
|
570 |
+
}
|
571 |
+
|
572 |
+
/**
|
573 |
+
* @return bool
|
574 |
+
*/
|
575 |
+
public function getFireAndForget() {
|
576 |
+
return $this->fireAndForget;
|
577 |
+
}
|
578 |
+
|
579 |
+
/**
|
580 |
+
* @param bool $fireAndForget
|
581 |
+
*/
|
582 |
+
public function setFireAndForget($fireAndForget) {
|
583 |
+
$this->fireAndForget = (bool)$fireAndForget;
|
584 |
+
}
|
585 |
+
|
586 |
+
/**
|
587 |
+
* @return \Closure|null
|
588 |
+
*/
|
589 |
+
public function getLoggingCallback() {
|
590 |
+
return $this->loggingCallback;
|
591 |
+
}
|
592 |
+
|
593 |
+
/**
|
594 |
+
* @param \Closure $callback
|
595 |
+
*/
|
596 |
+
public function setLoggingCallback(\Closure $callback) {
|
597 |
+
$this->loggingCallback = $callback;
|
598 |
+
}
|
599 |
+
|
600 |
+
/**
|
601 |
+
* @return float
|
602 |
+
*/
|
603 |
+
public function getRequestTimeout() {
|
604 |
+
return $this->requestTimeout;
|
605 |
+
}
|
606 |
+
|
607 |
+
/**
|
608 |
+
* @param float $requestTimeout
|
609 |
+
*/
|
610 |
+
public function setRequestTimeout($requestTimeout) {
|
611 |
+
$this->requestTimeout = (float)$requestTimeout;
|
612 |
+
}
|
613 |
+
|
614 |
+
/**
|
615 |
+
* @return string|null
|
616 |
+
*/
|
617 |
+
public function getEndPointHost() {
|
618 |
+
return $this->endPointHost;
|
619 |
+
}
|
620 |
+
|
621 |
+
/**
|
622 |
+
* @param string|null $endPointHost
|
623 |
+
*/
|
624 |
+
public function setEndPointHost($endPointHost) {
|
625 |
+
$this->endPointHost = $endPointHost;
|
626 |
+
}
|
627 |
+
|
628 |
+
/**
|
629 |
+
* @return string
|
630 |
+
*/
|
631 |
+
public function getEndPointPath() {
|
632 |
+
return $this->endPointPath;
|
633 |
+
}
|
634 |
+
|
635 |
+
/**
|
636 |
+
* @param string $endPointPath
|
637 |
+
*/
|
638 |
+
public function setEndPointPath($endPointPath) {
|
639 |
+
$this->endPointPath = $endPointPath;
|
640 |
+
}
|
641 |
+
|
642 |
+
/**
|
643 |
+
* @return bool
|
644 |
+
*/
|
645 |
+
public function getAnonymizeIpAddresses() {
|
646 |
+
return $this->anonymizeIpAddresses;
|
647 |
+
}
|
648 |
+
|
649 |
+
/**
|
650 |
+
* @param bool $anonymizeIpAddresses
|
651 |
+
*/
|
652 |
+
public function setAnonymizeIpAddresses($anonymizeIpAddresses) {
|
653 |
+
$this->anonymizeIpAddresses = $anonymizeIpAddresses;
|
654 |
+
}
|
655 |
+
|
656 |
+
/**
|
657 |
+
* @return int
|
658 |
+
*/
|
659 |
+
public function getSitespeedSampleRate() {
|
660 |
+
return $this->sitespeedSampleRate;
|
661 |
+
}
|
662 |
+
|
663 |
+
/**
|
664 |
+
* @param int $sitespeedSampleRate
|
665 |
+
*/
|
666 |
+
public function setSitespeedSampleRate($sitespeedSampleRate) {
|
667 |
+
if((int)$sitespeedSampleRate != (float)$sitespeedSampleRate || $sitespeedSampleRate < 0 || $sitespeedSampleRate > 100) {
|
668 |
+
return Tracker::_raiseError('For consistency with ga.js, sample rates must be specified as a number between 0 and 100.', __METHOD__);
|
669 |
+
}
|
670 |
+
|
671 |
+
$this->sitespeedSampleRate = (int)$sitespeedSampleRate;
|
672 |
+
}
|
673 |
+
|
674 |
+
}
|
675 |
+
|
676 |
+
}
|
677 |
+
|
678 |
+
|
679 |
+
|
680 |
+
/**
|
681 |
+
* Generic Server-Side Google Analytics PHP Client
|
682 |
+
*
|
683 |
+
* This library is free software; you can redistribute it and/or
|
684 |
+
* modify it under the terms of the GNU Lesser General Public
|
685 |
+
* License (LGPL) as published by the Free Software Foundation; either
|
686 |
+
* version 3 of the License, or (at your option) any later version.
|
687 |
+
*
|
688 |
+
* This library is distributed in the hope that it will be useful,
|
689 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
690 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
691 |
+
* Lesser General Public License for more details.
|
692 |
+
*
|
693 |
+
* You should have received a copy of the GNU Lesser General Public
|
694 |
+
* License along with this library; if not, write to the Free Software
|
695 |
+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
696 |
+
*
|
697 |
+
* Google Analytics is a registered trademark of Google Inc.
|
698 |
+
*
|
699 |
+
* @link http://code.google.com/p/php-ga
|
700 |
+
*
|
701 |
+
* @license http://www.gnu.org/licenses/lgpl.html
|
702 |
+
* @author Thomas Bachem <tb@unitedprototype.com>
|
703 |
+
* @copyright Copyright (c) 2010 United Prototype GmbH (http://unitedprototype.com)
|
704 |
+
*/
|
705 |
+
|
706 |
+
namespace UnitedPrototype\GoogleAnalytics{
|
707 |
+
|
708 |
+
use UnitedPrototype\GoogleAnalytics\Internals\Util;
|
709 |
+
|
710 |
+
/**
|
711 |
+
* @link http://code.google.com/apis/analytics/docs/tracking/gaTrackingCustomVariables.html
|
712 |
+
*/
|
713 |
+
class CustomVariable {
|
714 |
+
|
715 |
+
/**
|
716 |
+
* @var int
|
717 |
+
*/
|
718 |
+
protected $index;
|
719 |
+
|
720 |
+
/**
|
721 |
+
* WATCH OUT: It's a known issue that GA will not decode URL-encoded characters
|
722 |
+
* in custom variable names and values properly, so spaces will show up
|
723 |
+
* as "%20" in the interface etc.
|
724 |
+
*
|
725 |
+
* @link http://www.google.com/support/forum/p/Google%20Analytics/thread?tid=2cdb3ec0be32e078
|
726 |
+
* @var string
|
727 |
+
*/
|
728 |
+
protected $name;
|
729 |
+
|
730 |
+
/**
|
731 |
+
* WATCH OUT: It's a known issue that GA will not decode URL-encoded characters
|
732 |
+
* in custom variable names and values properly, so spaces will show up
|
733 |
+
* as "%20" in the interface etc.
|
734 |
+
*
|
735 |
+
* @link http://www.google.com/support/forum/p/Google%20Analytics/thread?tid=2cdb3ec0be32e078
|
736 |
+
* @var mixed
|
737 |
+
*/
|
738 |
+
protected $value;
|
739 |
+
|
740 |
+
/**
|
741 |
+
* See SCOPE_* constants
|
742 |
+
*
|
743 |
+
* @var int
|
744 |
+
*/
|
745 |
+
protected $scope = self::SCOPE_PAGE;
|
746 |
+
|
747 |
+
|
748 |
+
/**
|
749 |
+
* @const int
|
750 |
+
*/
|
751 |
+
const SCOPE_VISITOR = 1;
|
752 |
+
/**
|
753 |
+
* @const int
|
754 |
+
*/
|
755 |
+
const SCOPE_SESSION = 2;
|
756 |
+
/**
|
757 |
+
* @const int
|
758 |
+
*/
|
759 |
+
const SCOPE_PAGE = 3;
|
760 |
+
|
761 |
+
|
762 |
+
/**
|
763 |
+
* @param int $index
|
764 |
+
* @param string $name
|
765 |
+
* @param mixed $value
|
766 |
+
* @param int $scope See SCOPE_* constants
|
767 |
+
*/
|
768 |
+
public function __construct($index = null, $name = null, $value = null, $scope = null) {
|
769 |
+
if($index !== null) $this->setIndex($index);
|
770 |
+
if($name !== null) $this->setName($name);
|
771 |
+
if($value !== null) $this->setValue($value);
|
772 |
+
if($scope !== null) $this->setScope($scope);
|
773 |
+
}
|
774 |
+
|
775 |
+
public function validate() {
|
776 |
+
// According to the GA documentation, there is a limit to the combined size of
|
777 |
+
// name and value of 64 bytes after URL encoding,
|
778 |
+
// see http://code.google.com/apis/analytics/docs/tracking/gaTrackingCustomVariables.html#varTypes
|
779 |
+
// and http://xahlee.org/js/google_analytics_tracker_2010-07-01_expanded.js line 563
|
780 |
+
// This limit was increased to 128 bytes BEFORE encoding with the 2012-01 release of ga.js however,
|
781 |
+
// see http://code.google.com/apis/analytics/community/gajs_changelog.html
|
782 |
+
if(strlen($this->name . $this->value) > 128) {
|
783 |
+
Tracker::_raiseError('Custom Variable combined name and value length must not be larger than 128 bytes.', __METHOD__);
|
784 |
+
}
|
785 |
+
}
|
786 |
+
|
787 |
+
/**
|
788 |
+
* @return int
|
789 |
+
*/
|
790 |
+
public function getIndex() {
|
791 |
+
return $this->index;
|
792 |
+
}
|
793 |
+
|
794 |
+
/**
|
795 |
+
* @link http://code.google.com/intl/de-DE/apis/analytics/docs/tracking/gaTrackingCustomVariables.html#usage
|
796 |
+
* @param int $index
|
797 |
+
*/
|
798 |
+
public function setIndex($index) {
|
799 |
+
// Custom Variables are limited to five slots officially, but there seems to be a
|
800 |
+
// trick to allow for more of them which we could investigate at a later time (see
|
801 |
+
// http://analyticsimpact.com/2010/05/24/get-more-than-5-custom-variables-in-google-analytics/)
|
802 |
+
if($index < 1 || $index > 5) {
|
803 |
+
Tracker::_raiseError('Custom Variable index has to be between 1 and 5.', __METHOD__);
|
804 |
+
}
|
805 |
+
|
806 |
+
$this->index = (int)$index;
|
807 |
+
}
|
808 |
+
|
809 |
+
/**
|
810 |
+
* @return string
|
811 |
+
*/
|
812 |
+
public function getName() {
|
813 |
+
return $this->name;
|
814 |
+
}
|
815 |
+
|
816 |
+
/**
|
817 |
+
* @param string $name
|
818 |
+
*/
|
819 |
+
public function setName($name) {
|
820 |
+
$this->name = $name;
|
821 |
+
}
|
822 |
+
|
823 |
+
/**
|
824 |
+
* @return mixed
|
825 |
+
*/
|
826 |
+
public function getValue() {
|
827 |
+
return $this->value;
|
828 |
+
}
|
829 |
+
|
830 |
+
/**
|
831 |
+
* @param mixed $value
|
832 |
+
*/
|
833 |
+
public function setValue($value) {
|
834 |
+
$this->value = $value;
|
835 |
+
}
|
836 |
+
|
837 |
+
/**
|
838 |
+
* @return int
|
839 |
+
*/
|
840 |
+
public function getScope() {
|
841 |
+
return $this->scope;
|
842 |
+
}
|
843 |
+
|
844 |
+
/**
|
845 |
+
* @param int $scope
|
846 |
+
*/
|
847 |
+
public function setScope($scope) {
|
848 |
+
if(!in_array($scope, array(self::SCOPE_PAGE, self::SCOPE_SESSION, self::SCOPE_VISITOR))) {
|
849 |
+
Tracker::_raiseError('Custom Variable scope has to be one of the CustomVariable::SCOPE_* constant values.', __METHOD__);
|
850 |
+
}
|
851 |
+
|
852 |
+
$this->scope = (int)$scope;
|
853 |
+
}
|
854 |
+
|
855 |
+
}
|
856 |
+
|
857 |
+
}
|
858 |
+
|
859 |
+
|
860 |
+
|
861 |
+
|
862 |
+
/**
|
863 |
+
* Generic Server-Side Google Analytics PHP Client
|
864 |
+
*
|
865 |
+
* This library is free software; you can redistribute it and/or
|
866 |
+
* modify it under the terms of the GNU Lesser General Public
|
867 |
+
* License (LGPL) as published by the Free Software Foundation; either
|
868 |
+
* version 3 of the License, or (at your option) any later version.
|
869 |
+
*
|
870 |
+
* This library is distributed in the hope that it will be useful,
|
871 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
872 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
873 |
+
* Lesser General Public License for more details.
|
874 |
+
*
|
875 |
+
* You should have received a copy of the GNU Lesser General Public
|
876 |
+
* License along with this library; if not, write to the Free Software
|
877 |
+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
878 |
+
*
|
879 |
+
* Google Analytics is a registered trademark of Google Inc.
|
880 |
+
*
|
881 |
+
* @link http://code.google.com/p/php-ga
|
882 |
+
*
|
883 |
+
* @license http://www.gnu.org/licenses/lgpl.html
|
884 |
+
* @author Thomas Bachem <tb@unitedprototype.com>
|
885 |
+
* @copyright Copyright (c) 2010 United Prototype GmbH (http://unitedprototype.com)
|
886 |
+
*/
|
887 |
+
|
888 |
+
namespace UnitedPrototype\GoogleAnalytics{
|
889 |
+
|
890 |
+
/**
|
891 |
+
* @link http://code.google.com/apis/analytics/docs/tracking/eventTrackerOverview.html
|
892 |
+
* @link http://code.google.com/apis/analytics/docs/gaJS/gaJSApiEventTracking.html
|
893 |
+
*/
|
894 |
+
class Event {
|
895 |
+
|
896 |
+
/**
|
897 |
+
* The general event category (e.g. "Videos").
|
898 |
+
*
|
899 |
+
* @var string
|
900 |
+
*/
|
901 |
+
protected $category;
|
902 |
+
|
903 |
+
/**
|
904 |
+
* The action for the event (e.g. "Play").
|
905 |
+
*
|
906 |
+
* @var string
|
907 |
+
*/
|
908 |
+
protected $action;
|
909 |
+
|
910 |
+
/**
|
911 |
+
* An optional descriptor for the event (e.g. the video's title).
|
912 |
+
*
|
913 |
+
* @var string
|
914 |
+
*/
|
915 |
+
protected $label;
|
916 |
+
|
917 |
+
/**
|
918 |
+
* An optional value associated with the event. You can see your event values in the Overview,
|
919 |
+
* Categories, and Actions reports, where they are listed by event or aggregated across events,
|
920 |
+
* depending upon your report view.
|
921 |
+
*
|
922 |
+
* @var int
|
923 |
+
*/
|
924 |
+
protected $value;
|
925 |
+
|
926 |
+
/**
|
927 |
+
* Default value is false. By default, event hits will impact a visitor's bounce rate.
|
928 |
+
* By setting this parameter to true, this event hit will not be used in bounce rate calculations.
|
929 |
+
*
|
930 |
+
* @var bool
|
931 |
+
*/
|
932 |
+
protected $noninteraction = false;
|
933 |
+
|
934 |
+
|
935 |
+
/**
|
936 |
+
* @param string $category
|
937 |
+
* @param string $action
|
938 |
+
* @param string $label
|
939 |
+
* @param int $value
|
940 |
+
* @param bool $noninteraction
|
941 |
+
*/
|
942 |
+
public function __construct($category = null, $action = null, $label = null, $value = null, $noninteraction = null) {
|
943 |
+
if($category !== null) $this->setCategory($category);
|
944 |
+
if($action !== null) $this->setAction($action);
|
945 |
+
if($label !== null) $this->setLabel($label);
|
946 |
+
if($value !== null) $this->setValue($value);
|
947 |
+
if($noninteraction !== null) $this->setNoninteraction($noninteraction);
|
948 |
+
}
|
949 |
+
|
950 |
+
public function validate() {
|
951 |
+
if($this->category === null || $this->action === null) {
|
952 |
+
Tracker::_raiseError('Events need at least to have a category and action defined.', __METHOD__);
|
953 |
+
}
|
954 |
+
}
|
955 |
+
|
956 |
+
/**
|
957 |
+
* @return string
|
958 |
+
*/
|
959 |
+
public function getCategory() {
|
960 |
+
return $this->category;
|
961 |
+
}
|
962 |
+
|
963 |
+
/**
|
964 |
+
* @param string $category
|
965 |
+
*/
|
966 |
+
public function setCategory($category) {
|
967 |
+
$this->category = $category;
|
968 |
+
}
|
969 |
+
|
970 |
+
/**
|
971 |
+
* @return string
|
972 |
+
*/
|
973 |
+
public function getAction() {
|
974 |
+
return $this->action;
|
975 |
+
}
|
976 |
+
|
977 |
+
/**
|
978 |
+
* @param string $action
|
979 |
+
*/
|
980 |
+
public function setAction($action) {
|
981 |
+
$this->action = $action;
|
982 |
+
}
|
983 |
+
|
984 |
+
/**
|
985 |
+
* @return string
|
986 |
+
*/
|
987 |
+
public function getLabel() {
|
988 |
+
return $this->label;
|
989 |
+
}
|
990 |
+
|
991 |
+
/**
|
992 |
+
* @param string $label
|
993 |
+
*/
|
994 |
+
public function setLabel($label) {
|
995 |
+
$this->label = $label;
|
996 |
+
}
|
997 |
+
|
998 |
+
/**
|
999 |
+
* @return int
|
1000 |
+
*/
|
1001 |
+
public function getValue() {
|
1002 |
+
return $this->value;
|
1003 |
+
}
|
1004 |
+
|
1005 |
+
/**
|
1006 |
+
* @param int $value
|
1007 |
+
*/
|
1008 |
+
public function setValue($value) {
|
1009 |
+
$this->value = (int)$value;
|
1010 |
+
}
|
1011 |
+
|
1012 |
+
/**
|
1013 |
+
* @return bool
|
1014 |
+
*/
|
1015 |
+
public function getNoninteraction() {
|
1016 |
+
return $this->noninteraction;
|
1017 |
+
}
|
1018 |
+
|
1019 |
+
/**
|
1020 |
+
* @param bool $value
|
1021 |
+
*/
|
1022 |
+
public function setNoninteraction($value) {
|
1023 |
+
$this->noninteraction = (bool)$value;
|
1024 |
+
}
|
1025 |
+
|
1026 |
+
}
|
1027 |
+
|
1028 |
+
}
|
1029 |
+
|
1030 |
+
|
1031 |
+
|
1032 |
+
|
1033 |
+
/**
|
1034 |
+
* Generic Server-Side Google Analytics PHP Client
|
1035 |
+
*
|
1036 |
+
* This library is free software; you can redistribute it and/or
|
1037 |
+
* modify it under the terms of the GNU Lesser General Public
|
1038 |
+
* License (LGPL) as published by the Free Software Foundation; either
|
1039 |
+
* version 3 of the License, or (at your option) any later version.
|
1040 |
+
*
|
1041 |
+
* This library is distributed in the hope that it will be useful,
|
1042 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
1043 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
1044 |
+
* Lesser General Public License for more details.
|
1045 |
+
*
|
1046 |
+
* You should have received a copy of the GNU Lesser General Public
|
1047 |
+
* License along with this library; if not, write to the Free Software
|
1048 |
+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
1049 |
+
*
|
1050 |
+
* Google Analytics is a registered trademark of Google Inc.
|
1051 |
+
*
|
1052 |
+
* @link http://code.google.com/p/php-ga
|
1053 |
+
*
|
1054 |
+
* @license http://www.gnu.org/licenses/lgpl.html
|
1055 |
+
* @author Thomas Bachem <tb@unitedprototype.com>
|
1056 |
+
* @copyright Copyright (c) 2010 United Prototype GmbH (http://unitedprototype.com)
|
1057 |
+
*/
|
1058 |
+
|
1059 |
+
namespace UnitedPrototype\GoogleAnalytics{
|
1060 |
+
|
1061 |
+
/**
|
1062 |
+
* @see Config::$errorSeverity
|
1063 |
+
* @see Tracker::_raiseError()
|
1064 |
+
*/
|
1065 |
+
class Exception extends \Exception {
|
1066 |
+
|
1067 |
+
}
|
1068 |
+
}
|
1069 |
+
|
1070 |
+
|
1071 |
+
|
1072 |
+
|
1073 |
+
|
1074 |
+
/**
|
1075 |
+
* Generic Server-Side Google Analytics PHP Client
|
1076 |
+
*
|
1077 |
+
* This library is free software; you can redistribute it and/or
|
1078 |
+
* modify it under the terms of the GNU Lesser General Public
|
1079 |
+
* License (LGPL) as published by the Free Software Foundation; either
|
1080 |
+
* version 3 of the License, or (at your option) any later version.
|
1081 |
+
*
|
1082 |
+
* This library is distributed in the hope that it will be useful,
|
1083 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
1084 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
1085 |
+
* Lesser General Public License for more details.
|
1086 |
+
*
|
1087 |
+
* You should have received a copy of the GNU Lesser General Public
|
1088 |
+
* License along with this library; if not, write to the Free Software
|
1089 |
+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
1090 |
+
*
|
1091 |
+
* Google Analytics is a registered trademark of Google Inc.
|
1092 |
+
*
|
1093 |
+
* @link http://code.google.com/p/php-ga
|
1094 |
+
*
|
1095 |
+
* @license http://www.gnu.org/licenses/lgpl.html
|
1096 |
+
* @author Thomas Bachem <tb@unitedprototype.com>
|
1097 |
+
* @copyright Copyright (c) 2010 United Prototype GmbH (http://unitedprototype.com)
|
1098 |
+
*/
|
1099 |
+
|
1100 |
+
namespace UnitedPrototype\GoogleAnalytics{
|
1101 |
+
|
1102 |
+
/**
|
1103 |
+
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/ecommerce/Item.as
|
1104 |
+
*/
|
1105 |
+
class Item {
|
1106 |
+
|
1107 |
+
/**
|
1108 |
+
* Order ID, e.g. "a2343898", will be mapped to "utmtid" parameter
|
1109 |
+
*
|
1110 |
+
* @see Internals\ParameterHolder::$utmtid
|
1111 |
+
* @var string
|
1112 |
+
*/
|
1113 |
+
protected $orderId;
|
1114 |
+
|
1115 |
+
/**
|
1116 |
+
* Product Code. This is the sku code for a given product, e.g. "989898ajssi",
|
1117 |
+
* will be mapped to "utmipc" parameter
|
1118 |
+
*
|
1119 |
+
* @see Internals\ParameterHolder::$utmipc
|
1120 |
+
* @var string
|
1121 |
+
*/
|
1122 |
+
protected $sku;
|
1123 |
+
|
1124 |
+
/**
|
1125 |
+
* Product Name, e.g. "T-Shirt", will be mapped to "utmipn" parameter
|
1126 |
+
*
|
1127 |
+
* @see Internals\ParameterHolder::$utmipn
|
1128 |
+
* @var string
|
1129 |
+
*/
|
1130 |
+
protected $name;
|
1131 |
+
|
1132 |
+
/**
|
1133 |
+
* Variations on an item, e.g. "white", "black", "green" etc., will be mapped
|
1134 |
+
* to "utmiva" parameter
|
1135 |
+
*
|
1136 |
+
* @see Internals\ParameterHolder::$utmiva
|
1137 |
+
* @var string
|
1138 |
+
*/
|
1139 |
+
protected $variation;
|
1140 |
+
|
1141 |
+
/**
|
1142 |
+
* Unit Price. Value is set to numbers only (e.g. 19.95), will be mapped to
|
1143 |
+
* "utmipr" parameter
|
1144 |
+
*
|
1145 |
+
* @see Internals\ParameterHolder::$utmipr
|
1146 |
+
* @var float
|
1147 |
+
*/
|
1148 |
+
protected $price;
|
1149 |
+
|
1150 |
+
/**
|
1151 |
+
* Unit Quantity, e.g. 4, will be mapped to "utmiqt" parameter
|
1152 |
+
*
|
1153 |
+
* @see Internals\ParameterHolder::$utmiqt
|
1154 |
+
* @var int
|
1155 |
+
*/
|
1156 |
+
protected $quantity = 1;
|
1157 |
+
|
1158 |
+
|
1159 |
+
public function validate() {
|
1160 |
+
if($this->sku === null) {
|
1161 |
+
Tracker::_raiseError('Items need to have a sku/product code defined.', __METHOD__);
|
1162 |
+
}
|
1163 |
+
}
|
1164 |
+
|
1165 |
+
/**
|
1166 |
+
* @return string
|
1167 |
+
*/
|
1168 |
+
public function getOrderId() {
|
1169 |
+
return $this->orderId;
|
1170 |
+
}
|
1171 |
+
|
1172 |
+
/**
|
1173 |
+
* @param string $orderId
|
1174 |
+
*/
|
1175 |
+
public function setOrderId($orderId) {
|
1176 |
+
$this->orderId = $orderId;
|
1177 |
+
}
|
1178 |
+
|
1179 |
+
/**
|
1180 |
+
* @return string
|
1181 |
+
*/
|
1182 |
+
public function getSku() {
|
1183 |
+
return $this->sku;
|
1184 |
+
}
|
1185 |
+
|
1186 |
+
/**
|
1187 |
+
* @param string $sku
|
1188 |
+
*/
|
1189 |
+
public function setSku($sku) {
|
1190 |
+
$this->sku = $sku;
|
1191 |
+
}
|
1192 |
+
|
1193 |
+
/**
|
1194 |
+
* @return string
|
1195 |
+
*/
|
1196 |
+
public function getName() {
|
1197 |
+
return $this->name;
|
1198 |
+
}
|
1199 |
+
|
1200 |
+
/**
|
1201 |
+
* @param string $name
|
1202 |
+
*/
|
1203 |
+
public function setName($name) {
|
1204 |
+
$this->name = $name;
|
1205 |
+
}
|
1206 |
+
|
1207 |
+
/**
|
1208 |
+
* @return string
|
1209 |
+
*/
|
1210 |
+
public function getVariation() {
|
1211 |
+
return $this->variation;
|
1212 |
+
}
|
1213 |
+
|
1214 |
+
/**
|
1215 |
+
* @param string $variation
|
1216 |
+
*/
|
1217 |
+
public function setVariation($variation) {
|
1218 |
+
$this->variation = $variation;
|
1219 |
+
}
|
1220 |
+
|
1221 |
+
/**
|
1222 |
+
* @return float
|
1223 |
+
*/
|
1224 |
+
public function getPrice() {
|
1225 |
+
return $this->price;
|
1226 |
+
}
|
1227 |
+
|
1228 |
+
/**
|
1229 |
+
* @param float $price
|
1230 |
+
*/
|
1231 |
+
public function setPrice($price) {
|
1232 |
+
$this->price = (float)$price;
|
1233 |
+
}
|
1234 |
+
|
1235 |
+
/**
|
1236 |
+
* @return int
|
1237 |
+
*/
|
1238 |
+
public function getQuantity() {
|
1239 |
+
return $this->quantity;
|
1240 |
+
}
|
1241 |
+
|
1242 |
+
/**
|
1243 |
+
* @param int $quantity
|
1244 |
+
*/
|
1245 |
+
public function setQuantity($quantity) {
|
1246 |
+
$this->quantity = (int)$quantity;
|
1247 |
+
}
|
1248 |
+
|
1249 |
+
}
|
1250 |
+
|
1251 |
+
}
|
1252 |
+
|
1253 |
+
|
1254 |
+
|
1255 |
+
|
1256 |
+
|
1257 |
+
/**
|
1258 |
+
* Generic Server-Side Google Analytics PHP Client
|
1259 |
+
*
|
1260 |
+
* This library is free software; you can redistribute it and/or
|
1261 |
+
* modify it under the terms of the GNU Lesser General Public
|
1262 |
+
* License (LGPL) as published by the Free Software Foundation; either
|
1263 |
+
* version 3 of the License, or (at your option) any later version.
|
1264 |
+
*
|
1265 |
+
* This library is distributed in the hope that it will be useful,
|
1266 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
1267 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
1268 |
+
* Lesser General Public License for more details.
|
1269 |
+
*
|
1270 |
+
* You should have received a copy of the GNU Lesser General Public
|
1271 |
+
* License along with this library; if not, write to the Free Software
|
1272 |
+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
1273 |
+
*
|
1274 |
+
* Google Analytics is a registered trademark of Google Inc.
|
1275 |
+
*
|
1276 |
+
* @link http://code.google.com/p/php-ga
|
1277 |
+
*
|
1278 |
+
* @license http://www.gnu.org/licenses/lgpl.html
|
1279 |
+
* @author Thomas Bachem <tb@unitedprototype.com>
|
1280 |
+
* @copyright Copyright (c) 2010 United Prototype GmbH (http://unitedprototype.com)
|
1281 |
+
*/
|
1282 |
+
|
1283 |
+
namespace UnitedPrototype\GoogleAnalytics{
|
1284 |
+
|
1285 |
+
class Page {
|
1286 |
+
|
1287 |
+
/**
|
1288 |
+
* Page request URI, e.g. "/path/page.html", will be mapped to
|
1289 |
+
* "utmp" parameter
|
1290 |
+
*
|
1291 |
+
* @see Internals\ParameterHolder::$utmp
|
1292 |
+
* @var string
|
1293 |
+
*/
|
1294 |
+
protected $path;
|
1295 |
+
|
1296 |
+
/**
|
1297 |
+
* Page title, will be mapped to "utmdt" parameter
|
1298 |
+
*
|
1299 |
+
* @see Internals\ParameterHolder::$utmdt
|
1300 |
+
* @var string
|
1301 |
+
*/
|
1302 |
+
protected $title;
|
1303 |
+
|
1304 |
+
/**
|
1305 |
+
* Charset encoding (e.g. "UTF-8"), will be mapped to "utmcs" parameter
|
1306 |
+
*
|
1307 |
+
* @see Internals\ParameterHolder::$utmcs
|
1308 |
+
* @var string
|
1309 |
+
*/
|
1310 |
+
protected $charset;
|
1311 |
+
|
1312 |
+
/**
|
1313 |
+
* Referer URL, e.g. "http://www.example.com/path/page.html", will be
|
1314 |
+
* mapped to "utmr" parameter
|
1315 |
+
*
|
1316 |
+
* @see Internals\ParameterHolder::$utmr
|
1317 |
+
* @var string
|
1318 |
+
*/
|
1319 |
+
protected $referrer;
|
1320 |
+
|
1321 |
+
/**
|
1322 |
+
* Page load time in milliseconds, will be encoded into "utme" parameter.
|
1323 |
+
*
|
1324 |
+
* @see Internals\ParameterHolder::$utme
|
1325 |
+
* @var int
|
1326 |
+
*/
|
1327 |
+
protected $loadTime;
|
1328 |
+
|
1329 |
+
|
1330 |
+
/**
|
1331 |
+
* Constant to mark referrer as a site-internal one.
|
1332 |
+
*
|
1333 |
+
* @see Page::$referrer
|
1334 |
+
* @const string
|
1335 |
+
*/
|
1336 |
+
const REFERRER_INTERNAL = '0';
|
1337 |
+
|
1338 |
+
|
1339 |
+
/**
|
1340 |
+
* @param string $path
|
1341 |
+
*/
|
1342 |
+
public function __construct($path) {
|
1343 |
+
$this->setPath($path);
|
1344 |
+
}
|
1345 |
+
|
1346 |
+
/**
|
1347 |
+
* @param string $path
|
1348 |
+
*/
|
1349 |
+
public function setPath($path) {
|
1350 |
+
if($path && $path[0] != '/') {
|
1351 |
+
Tracker::_raiseError('The page path should always start with a slash ("/").', __METHOD__);
|
1352 |
+
}
|
1353 |
+
|
1354 |
+
$this->path = $path;
|
1355 |
+
}
|
1356 |
+
|
1357 |
+
/**
|
1358 |
+
* @return string
|
1359 |
+
*/
|
1360 |
+
public function getPath() {
|
1361 |
+
return $this->path;
|
1362 |
+
}
|
1363 |
+
|
1364 |
+
/**
|
1365 |
+
* @param string $title
|
1366 |
+
*/
|
1367 |
+
public function setTitle($title) {
|
1368 |
+
$this->title = $title;
|
1369 |
+
}
|
1370 |
+
|
1371 |
+
/**
|
1372 |
+
* @return string
|
1373 |
+
*/
|
1374 |
+
public function getTitle() {
|
1375 |
+
return $this->title;
|
1376 |
+
}
|
1377 |
+
|
1378 |
+
/**
|
1379 |
+
* @param string $charset
|
1380 |
+
*/
|
1381 |
+
public function setCharset($encoding) {
|
1382 |
+
$this->charset = $encoding;
|
1383 |
+
}
|
1384 |
+
|
1385 |
+
/**
|
1386 |
+
* @return string
|
1387 |
+
*/
|
1388 |
+
public function getCharset() {
|
1389 |
+
return $this->charset;
|
1390 |
+
}
|
1391 |
+
|
1392 |
+
/**
|
1393 |
+
* @param string $referrer
|
1394 |
+
*/
|
1395 |
+
public function setReferrer($referrer) {
|
1396 |
+
$this->referrer = $referrer;
|
1397 |
+
}
|
1398 |
+
|
1399 |
+
/**
|
1400 |
+
* @return string
|
1401 |
+
*/
|
1402 |
+
public function getReferrer() {
|
1403 |
+
return $this->referrer;
|
1404 |
+
}
|
1405 |
+
|
1406 |
+
/**
|
1407 |
+
* @param int $loadTime
|
1408 |
+
*/
|
1409 |
+
public function setLoadTime($loadTime) {
|
1410 |
+
if((int)$loadTime != (float)$loadTime) {
|
1411 |
+
return Tracker::_raiseError('Page load time must be specified in integer milliseconds.', __METHOD__);
|
1412 |
+
}
|
1413 |
+
|
1414 |
+
$this->loadTime = (int)$loadTime;
|
1415 |
+
}
|
1416 |
+
|
1417 |
+
/**
|
1418 |
+
* @return int
|
1419 |
+
*/
|
1420 |
+
public function getLoadTime() {
|
1421 |
+
return $this->loadTime;
|
1422 |
+
}
|
1423 |
+
|
1424 |
+
}
|
1425 |
+
|
1426 |
+
}
|
1427 |
+
|
1428 |
+
|
1429 |
+
|
1430 |
+
|
1431 |
+
/**
|
1432 |
+
* Generic Server-Side Google Analytics PHP Client
|
1433 |
+
*
|
1434 |
+
* This library is free software; you can redistribute it and/or
|
1435 |
+
* modify it under the terms of the GNU Lesser General Public
|
1436 |
+
* License (LGPL) as published by the Free Software Foundation; either
|
1437 |
+
* version 3 of the License, or (at your option) any later version.
|
1438 |
+
*
|
1439 |
+
* This library is distributed in the hope that it will be useful,
|
1440 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
1441 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
1442 |
+
* Lesser General Public License for more details.
|
1443 |
+
*
|
1444 |
+
* You should have received a copy of the GNU Lesser General Public
|
1445 |
+
* License along with this library; if not, write to the Free Software
|
1446 |
+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
1447 |
+
*
|
1448 |
+
* Google Analytics is a registered trademark of Google Inc.
|
1449 |
+
*
|
1450 |
+
* @link http://code.google.com/p/php-ga
|
1451 |
+
*
|
1452 |
+
* @license http://www.gnu.org/licenses/lgpl.html
|
1453 |
+
* @author Thomas Bachem <tb@unitedprototype.com>
|
1454 |
+
* @copyright Copyright (c) 2010 United Prototype GmbH (http://unitedprototype.com)
|
1455 |
+
*/
|
1456 |
+
|
1457 |
+
namespace UnitedPrototype\GoogleAnalytics{
|
1458 |
+
|
1459 |
+
use UnitedPrototype\GoogleAnalytics\Internals\Util;
|
1460 |
+
|
1461 |
+
use DateTime;
|
1462 |
+
|
1463 |
+
/**
|
1464 |
+
* You should serialize this object and store it in the user session to keep it
|
1465 |
+
* persistent between requests (similar to the "__umtb" cookie of
|
1466 |
+
* the GA Javascript client).
|
1467 |
+
*/
|
1468 |
+
class Session {
|
1469 |
+
|
1470 |
+
/**
|
1471 |
+
* A unique per-session ID, will be mapped to "utmhid" parameter
|
1472 |
+
*
|
1473 |
+
* @see Internals\ParameterHolder::$utmhid
|
1474 |
+
* @var int
|
1475 |
+
*/
|
1476 |
+
protected $sessionId;
|
1477 |
+
|
1478 |
+
/**
|
1479 |
+
* The amount of pageviews that were tracked within this session so far,
|
1480 |
+
* will be part of the "__utmb" cookie parameter.
|
1481 |
+
*
|
1482 |
+
* Will get incremented automatically upon each request.
|
1483 |
+
*
|
1484 |
+
* @see Internals\ParameterHolder::$__utmb
|
1485 |
+
* @see Internals\Request\Request::buildHttpRequest()
|
1486 |
+
* @var int
|
1487 |
+
*/
|
1488 |
+
protected $trackCount;
|
1489 |
+
|
1490 |
+
/**
|
1491 |
+
* Timestamp of the start of this new session, will be part of the "__utmb"
|
1492 |
+
* cookie parameter
|
1493 |
+
*
|
1494 |
+
* @see Internals\ParameterHolder::$__utmb
|
1495 |
+
* @var DateTime
|
1496 |
+
*/
|
1497 |
+
protected $startTime;
|
1498 |
+
|
1499 |
+
|
1500 |
+
public function __construct() {
|
1501 |
+
$this->setSessionId($this->generateSessionId());
|
1502 |
+
$this->setTrackCount(0);
|
1503 |
+
$this->setStartTime(new DateTime());
|
1504 |
+
}
|
1505 |
+
|
1506 |
+
/**
|
1507 |
+
* Will extract information for the "trackCount" and "startTime"
|
1508 |
+
* properties from the given "__utmb" cookie value.
|
1509 |
+
*
|
1510 |
+
* @see Internals\ParameterHolder::$__utmb
|
1511 |
+
* @see Internals\Request\Request::buildCookieParameters()
|
1512 |
+
* @param string $value
|
1513 |
+
* @return $this
|
1514 |
+
*/
|
1515 |
+
public function fromUtmb($value) {
|
1516 |
+
$parts = explode('.', $value);
|
1517 |
+
if(count($parts) != 4) {
|
1518 |
+
Tracker::_raiseError('The given "__utmb" cookie value is invalid.', __METHOD__);
|
1519 |
+
return $this;
|
1520 |
+
}
|
1521 |
+
|
1522 |
+
$this->setTrackCount($parts[1]);
|
1523 |
+
$this->setStartTime(new DateTime('@' . $parts[3]));
|
1524 |
+
|
1525 |
+
// Allow chaining
|
1526 |
+
return $this;
|
1527 |
+
}
|
1528 |
+
|
1529 |
+
/**
|
1530 |
+
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/core/DocumentInfo.as#52
|
1531 |
+
* @return int
|
1532 |
+
*/
|
1533 |
+
protected function generateSessionId() {
|
1534 |
+
// TODO: Integrate AdSense support
|
1535 |
+
return Util::generate32bitRandom();
|
1536 |
+
}
|
1537 |
+
|
1538 |
+
/**
|
1539 |
+
* @return int
|
1540 |
+
*/
|
1541 |
+
public function getSessionId() {
|
1542 |
+
return $this->sessionId;
|
1543 |
+
}
|
1544 |
+
|
1545 |
+
/**
|
1546 |
+
* @param int $sessionId
|
1547 |
+
*/
|
1548 |
+
public function setSessionId($sessionId) {
|
1549 |
+
$this->sessionId = $sessionId;
|
1550 |
+
}
|
1551 |
+
|
1552 |
+
/**
|
1553 |
+
* @return int
|
1554 |
+
*/
|
1555 |
+
public function getTrackCount() {
|
1556 |
+
return $this->trackCount;
|
1557 |
+
}
|
1558 |
+
|
1559 |
+
/**
|
1560 |
+
* @param int $trackCount
|
1561 |
+
*/
|
1562 |
+
public function setTrackCount($trackCount) {
|
1563 |
+
$this->trackCount = (int)$trackCount;
|
1564 |
+
}
|
1565 |
+
|
1566 |
+
/**
|
1567 |
+
* @param int $byAmount
|
1568 |
+
*/
|
1569 |
+
public function increaseTrackCount($byAmount = 1) {
|
1570 |
+
$this->trackCount += $byAmount;
|
1571 |
+
}
|
1572 |
+
|
1573 |
+
/**
|
1574 |
+
* @return DateTime
|
1575 |
+
*/
|
1576 |
+
public function getStartTime() {
|
1577 |
+
return $this->startTime;
|
1578 |
+
}
|
1579 |
+
|
1580 |
+
/**
|
1581 |
+
* @param DateTime $startTime
|
1582 |
+
*/
|
1583 |
+
public function setStartTime(DateTime $startTime) {
|
1584 |
+
$this->startTime = $startTime;
|
1585 |
+
}
|
1586 |
+
|
1587 |
+
}
|
1588 |
+
|
1589 |
+
}
|
1590 |
+
|
1591 |
+
|
1592 |
+
|
1593 |
+
/**
|
1594 |
+
* Generic Server-Side Google Analytics PHP Client
|
1595 |
+
*
|
1596 |
+
* This library is free software; you can redistribute it and/or
|
1597 |
+
* modify it under the terms of the GNU Lesser General Public
|
1598 |
+
* License (LGPL) as published by the Free Software Foundation; either
|
1599 |
+
* version 3 of the License, or (at your option) any later version.
|
1600 |
+
*
|
1601 |
+
* This library is distributed in the hope that it will be useful,
|
1602 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
1603 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
1604 |
+
* Lesser General Public License for more details.
|
1605 |
+
*
|
1606 |
+
* You should have received a copy of the GNU Lesser General Public
|
1607 |
+
* License along with this library; if not, write to the Free Software
|
1608 |
+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
1609 |
+
*
|
1610 |
+
* Google Analytics is a registered trademark of Google Inc.
|
1611 |
+
*
|
1612 |
+
* @link http://code.google.com/p/php-ga
|
1613 |
+
*
|
1614 |
+
* @license http://www.gnu.org/licenses/lgpl.html
|
1615 |
+
* @author Thomas Bachem <tb@unitedprototype.com>
|
1616 |
+
* @copyright Copyright (c) 2010 United Prototype GmbH (http://unitedprototype.com)
|
1617 |
+
*/
|
1618 |
+
|
1619 |
+
namespace UnitedPrototype\GoogleAnalytics{
|
1620 |
+
|
1621 |
+
class SocialInteraction {
|
1622 |
+
|
1623 |
+
/**
|
1624 |
+
* Required. A string representing the social network being tracked (e.g. "Facebook", "Twitter", "LinkedIn", ...),
|
1625 |
+
* will be mapped to "utmsn" parameter
|
1626 |
+
*
|
1627 |
+
* @see Internals\ParameterHolder::$utmsn
|
1628 |
+
* @var string
|
1629 |
+
*/
|
1630 |
+
protected $network;
|
1631 |
+
|
1632 |
+
/**
|
1633 |
+
* Required. A string representing the social action being tracked (e.g. "Like", "Share", "Tweet", ...),
|
1634 |
+
* will be mapped to "utmsa" parameter
|
1635 |
+
*
|
1636 |
+
* @see Internals\ParameterHolder::$utmsa
|
1637 |
+
* @var string
|
1638 |
+
*/
|
1639 |
+
protected $action;
|
1640 |
+
|
1641 |
+
/**
|
1642 |
+
* Optional. A string representing the URL (or resource) which receives the action. For example,
|
1643 |
+
* if a user clicks the Like button on a page on a site, the the target might be set to the title
|
1644 |
+
* of the page, or an ID used to identify the page in a content management system. In many cases,
|
1645 |
+
* the page you Like is the same page you are on. So if this parameter is not given, we will default
|
1646 |
+
* to using the path of the corresponding Page object.
|
1647 |
+
*
|
1648 |
+
* @see Internals\ParameterHolder::$utmsid
|
1649 |
+
* @var string
|
1650 |
+
*/
|
1651 |
+
protected $target;
|
1652 |
+
|
1653 |
+
|
1654 |
+
/**
|
1655 |
+
* @param string $path
|
1656 |
+
*/
|
1657 |
+
public function __construct($network = null, $action = null, $target = null) {
|
1658 |
+
if($network !== null) $this->setNetwork($network);
|
1659 |
+
if($action !== null) $this->setAction($action);
|
1660 |
+
if($target !== null) $this->setTarget($target);
|
1661 |
+
}
|
1662 |
+
|
1663 |
+
public function validate() {
|
1664 |
+
if($this->network === null || $this->action === null) {
|
1665 |
+
Tracker::_raiseError('Social interactions need to have at least the "network" and "action" attributes defined.', __METHOD__);
|
1666 |
+
}
|
1667 |
+
}
|
1668 |
+
|
1669 |
+
/**
|
1670 |
+
* @param string $network
|
1671 |
+
*/
|
1672 |
+
public function setNetwork($network) {
|
1673 |
+
$this->network = $network;
|
1674 |
+
}
|
1675 |
+
|
1676 |
+
/**
|
1677 |
+
* @return string
|
1678 |
+
*/
|
1679 |
+
public function getNetwork() {
|
1680 |
+
return $this->network;
|
1681 |
+
}
|
1682 |
+
|
1683 |
+
/**
|
1684 |
+
* @param string $action
|
1685 |
+
*/
|
1686 |
+
public function setAction($action) {
|
1687 |
+
$this->action = $action;
|
1688 |
+
}
|
1689 |
+
|
1690 |
+
/**
|
1691 |
+
* @return string
|
1692 |
+
*/
|
1693 |
+
public function getAction() {
|
1694 |
+
return $this->action;
|
1695 |
+
}
|
1696 |
+
|
1697 |
+
/**
|
1698 |
+
* @param string $target
|
1699 |
+
*/
|
1700 |
+
public function setTarget($target) {
|
1701 |
+
$this->target = $target;
|
1702 |
+
}
|
1703 |
+
|
1704 |
+
/**
|
1705 |
+
* @return string
|
1706 |
+
*/
|
1707 |
+
public function getTarget() {
|
1708 |
+
return $this->target;
|
1709 |
+
}
|
1710 |
+
|
1711 |
+
}
|
1712 |
+
|
1713 |
+
}
|
1714 |
+
|
1715 |
+
|
1716 |
+
|
1717 |
+
|
1718 |
+
/**
|
1719 |
+
* Generic Server-Side Google Analytics PHP Client
|
1720 |
+
*
|
1721 |
+
* This library is free software; you can redistribute it and/or
|
1722 |
+
* modify it under the terms of the GNU Lesser General Public
|
1723 |
+
* License (LGPL) as published by the Free Software Foundation; either
|
1724 |
+
* version 3 of the License, or (at your option) any later version.
|
1725 |
+
*
|
1726 |
+
* This library is distributed in the hope that it will be useful,
|
1727 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
1728 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
1729 |
+
* Lesser General Public License for more details.
|
1730 |
+
*
|
1731 |
+
* You should have received a copy of the GNU Lesser General Public
|
1732 |
+
* License along with this library; if not, write to the Free Software
|
1733 |
+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
1734 |
+
*
|
1735 |
+
* Google Analytics is a registered trademark of Google Inc.
|
1736 |
+
*
|
1737 |
+
* @link http://code.google.com/p/php-ga
|
1738 |
+
*
|
1739 |
+
* @license http://www.gnu.org/licenses/lgpl.html
|
1740 |
+
* @author Thomas Bachem <tb@unitedprototype.com>
|
1741 |
+
* @copyright Copyright (c) 2010 United Prototype GmbH (http://unitedprototype.com)
|
1742 |
+
*/
|
1743 |
+
|
1744 |
+
namespace UnitedPrototype\GoogleAnalytics{
|
1745 |
+
|
1746 |
+
use UnitedPrototype\GoogleAnalytics\Internals\Util;
|
1747 |
+
use UnitedPrototype\GoogleAnalytics\Internals\Request\PageviewRequest;
|
1748 |
+
use UnitedPrototype\GoogleAnalytics\Internals\Request\EventRequest;
|
1749 |
+
use UnitedPrototype\GoogleAnalytics\Internals\Request\TransactionRequest;
|
1750 |
+
use UnitedPrototype\GoogleAnalytics\Internals\Request\ItemRequest;
|
1751 |
+
use UnitedPrototype\GoogleAnalytics\Internals\Request\SocialInteractionRequest;
|
1752 |
+
|
1753 |
+
class Tracker {
|
1754 |
+
|
1755 |
+
/**
|
1756 |
+
* Google Analytics client version on which this library is built upon,
|
1757 |
+
* will be mapped to "utmwv" parameter.
|
1758 |
+
*
|
1759 |
+
* This doesn't necessarily mean that all features of the corresponding
|
1760 |
+
* ga.js version are implemented but rather that the requests comply
|
1761 |
+
* with these of ga.js.
|
1762 |
+
*
|
1763 |
+
* @link http://code.google.com/apis/analytics/docs/gaJS/changelog.html
|
1764 |
+
* @const string
|
1765 |
+
*/
|
1766 |
+
const VERSION = '5.2.5'; // As of 25.02.2012
|
1767 |
+
|
1768 |
+
|
1769 |
+
/**
|
1770 |
+
* The configuration to use for all tracker instances.
|
1771 |
+
*
|
1772 |
+
* @var \UnitedPrototype\GoogleAnalytics\Config
|
1773 |
+
*/
|
1774 |
+
protected static $config;
|
1775 |
+
|
1776 |
+
/**
|
1777 |
+
* Google Analytics account ID, e.g. "UA-1234567-8", will be mapped to
|
1778 |
+
* "utmac" parameter
|
1779 |
+
*
|
1780 |
+
* @see Internals\ParameterHolder::$utmac
|
1781 |
+
* @var string
|
1782 |
+
*/
|
1783 |
+
protected $accountId;
|
1784 |
+
|
1785 |
+
/**
|
1786 |
+
* Host Name, e.g. "www.example.com", will be mapped to "utmhn" parameter
|
1787 |
+
*
|
1788 |
+
* @see Internals\ParameterHolder::$utmhn
|
1789 |
+
* @var string
|
1790 |
+
*/
|
1791 |
+
protected $domainName;
|
1792 |
+
|
1793 |
+
/**
|
1794 |
+
* Whether to generate a unique domain hash, default is true to be consistent
|
1795 |
+
* with the GA Javascript Client
|
1796 |
+
*
|
1797 |
+
* @link http://code.google.com/apis/analytics/docs/tracking/gaTrackingSite.html#setAllowHash
|
1798 |
+
* @see Internals\Request\Request::generateDomainHash()
|
1799 |
+
* @var bool
|
1800 |
+
*/
|
1801 |
+
protected $allowHash = true;
|
1802 |
+
|
1803 |
+
/**
|
1804 |
+
* @var array
|
1805 |
+
*/
|
1806 |
+
protected $customVariables = array();
|
1807 |
+
|
1808 |
+
/**
|
1809 |
+
* @var \UnitedPrototype\GoogleAnalytics\Campaign
|
1810 |
+
*/
|
1811 |
+
protected $campaign;
|
1812 |
+
|
1813 |
+
|
1814 |
+
/**
|
1815 |
+
* @param string $accountId
|
1816 |
+
* @param string $domainName
|
1817 |
+
* @param \UnitedPrototype\GoogleAnalytics\Config $config
|
1818 |
+
*/
|
1819 |
+
public function __construct($accountId, $domainName, Config $config = null) {
|
1820 |
+
static::setConfig($config ? $config : new Config());
|
1821 |
+
|
1822 |
+
$this->setAccountId($accountId);
|
1823 |
+
$this->setDomainName($domainName);
|
1824 |
+
}
|
1825 |
+
|
1826 |
+
/**
|
1827 |
+
* @return \UnitedPrototype\GoogleAnalytics\Config
|
1828 |
+
*/
|
1829 |
+
public static function getConfig() {
|
1830 |
+
return static::$config;
|
1831 |
+
}
|
1832 |
+
|
1833 |
+
/**
|
1834 |
+
* @param \UnitedPrototype\GoogleAnalytics\Config $value
|
1835 |
+
*/
|
1836 |
+
public static function setConfig(Config $value) {
|
1837 |
+
static::$config = $value;
|
1838 |
+
}
|
1839 |
+
|
1840 |
+
/**
|
1841 |
+
* @param string $value
|
1842 |
+
*/
|
1843 |
+
public function setAccountId($value) {
|
1844 |
+
if(!preg_match('/^(UA|MO)-[0-9]*-[0-9]*$/', $value)) {
|
1845 |
+
static::_raiseError('"' . $value . '" is not a valid Google Analytics account ID.', __METHOD__);
|
1846 |
+
}
|
1847 |
+
|
1848 |
+
$this->accountId = $value;
|
1849 |
+
}
|
1850 |
+
|
1851 |
+
/**
|
1852 |
+
* @return string
|
1853 |
+
*/
|
1854 |
+
public function getAccountId() {
|
1855 |
+
return $this->accountId;
|
1856 |
+
}
|
1857 |
+
|
1858 |
+
/**
|
1859 |
+
* @param string $value
|
1860 |
+
*/
|
1861 |
+
public function setDomainName($value) {
|
1862 |
+
$this->domainName = $value;
|
1863 |
+
}
|
1864 |
+
|
1865 |
+
/**
|
1866 |
+
* @return string
|
1867 |
+
*/
|
1868 |
+
public function getDomainName() {
|
1869 |
+
return $this->domainName;
|
1870 |
+
}
|
1871 |
+
|
1872 |
+
/**
|
1873 |
+
* @param bool $value
|
1874 |
+
*/
|
1875 |
+
public function setAllowHash($value) {
|
1876 |
+
$this->allowHash = (bool)$value;
|
1877 |
+
}
|
1878 |
+
|
1879 |
+
/**
|
1880 |
+
* @return bool
|
1881 |
+
*/
|
1882 |
+
public function getAllowHash() {
|
1883 |
+
return $this->allowHash;
|
1884 |
+
}
|
1885 |
+
|
1886 |
+
/**
|
1887 |
+
* Equivalent of _setCustomVar() in GA Javascript client.
|
1888 |
+
*
|
1889 |
+
* @link http://code.google.com/apis/analytics/docs/tracking/gaTrackingCustomVariables.html
|
1890 |
+
* @param \UnitedPrototype\GoogleAnalytics\CustomVariable $customVariable
|
1891 |
+
*/
|
1892 |
+
public function addCustomVariable(CustomVariable $customVariable) {
|
1893 |
+
// Ensure that all required parameters are set
|
1894 |
+
$customVariable->validate();
|
1895 |
+
|
1896 |
+
$index = $customVariable->getIndex();
|
1897 |
+
$this->customVariables[$index] = $customVariable;
|
1898 |
+
}
|
1899 |
+
|
1900 |
+
/**
|
1901 |
+
* @return \UnitedPrototype\GoogleAnalytics\CustomVariable[]
|
1902 |
+
*/
|
1903 |
+
public function getCustomVariables() {
|
1904 |
+
return $this->customVariables;
|
1905 |
+
}
|
1906 |
+
|
1907 |
+
/**
|
1908 |
+
* Equivalent of _deleteCustomVar() in GA Javascript client.
|
1909 |
+
*
|
1910 |
+
* @param int $index
|
1911 |
+
*/
|
1912 |
+
public function removeCustomVariable($index) {
|
1913 |
+
unset($this->customVariables[$index]);
|
1914 |
+
}
|
1915 |
+
|
1916 |
+
/**
|
1917 |
+
* @param \UnitedPrototype\GoogleAnalytics\Campaign $campaign Isn't really optional, but can be set to null
|
1918 |
+
*/
|
1919 |
+
public function setCampaign(Campaign $campaign = null) {
|
1920 |
+
if($campaign) {
|
1921 |
+
// Ensure that all required parameters are set
|
1922 |
+
$campaign->validate();
|
1923 |
+
}
|
1924 |
+
|
1925 |
+
$this->campaign = $campaign;
|
1926 |
+
}
|
1927 |
+
|
1928 |
+
/**
|
1929 |
+
* @return \UnitedPrototype\GoogleAnalytics\Campaign|null
|
1930 |
+
*/
|
1931 |
+
public function getCampaign() {
|
1932 |
+
return $this->campaign;
|
1933 |
+
}
|
1934 |
+
|
1935 |
+
/**
|
1936 |
+
* Equivalent of _trackPageview() in GA Javascript client.
|
1937 |
+
*
|
1938 |
+
* @link http://code.google.com/apis/analytics/docs/gaJS/gaJSApiBasicConfiguration.html#_gat.GA_Tracker_._trackPageview
|
1939 |
+
* @param \UnitedPrototype\GoogleAnalytics\Page $page
|
1940 |
+
* @param \UnitedPrototype\GoogleAnalytics\Session $session
|
1941 |
+
* @param \UnitedPrototype\GoogleAnalytics\Visitor $visitor
|
1942 |
+
*/
|
1943 |
+
public function trackPageview(Page $page, Session $session, Visitor $visitor) {
|
1944 |
+
$request = new PageviewRequest(static::$config);
|
1945 |
+
$request->setPage($page);
|
1946 |
+
$request->setSession($session);
|
1947 |
+
$request->setVisitor($visitor);
|
1948 |
+
$request->setTracker($this);
|
1949 |
+
$request->fire();
|
1950 |
+
}
|
1951 |
+
|
1952 |
+
/**
|
1953 |
+
* Equivalent of _trackEvent() in GA Javascript client.
|
1954 |
+
*
|
1955 |
+
* @link http://code.google.com/apis/analytics/docs/gaJS/gaJSApiEventTracking.html#_gat.GA_EventTracker_._trackEvent
|
1956 |
+
* @param \UnitedPrototype\GoogleAnalytics\Event $event
|
1957 |
+
* @param \UnitedPrototype\GoogleAnalytics\Session $session
|
1958 |
+
* @param \UnitedPrototype\GoogleAnalytics\Visitor $visitor
|
1959 |
+
*/
|
1960 |
+
public function trackEvent(Event $event, Session $session, Visitor $visitor) {
|
1961 |
+
// Ensure that all required parameters are set
|
1962 |
+
$event->validate();
|
1963 |
+
|
1964 |
+
$request = new EventRequest(static::$config);
|
1965 |
+
$request->setEvent($event);
|
1966 |
+
$request->setSession($session);
|
1967 |
+
$request->setVisitor($visitor);
|
1968 |
+
$request->setTracker($this);
|
1969 |
+
$request->fire();
|
1970 |
+
}
|
1971 |
+
|
1972 |
+
/**
|
1973 |
+
* Combines _addTrans(), _addItem() (indirectly) and _trackTrans() of GA Javascript client.
|
1974 |
+
* Although the naming of "_addTrans()" would suggest multiple possible transactions
|
1975 |
+
* per request, there is just one allowed actually.
|
1976 |
+
*
|
1977 |
+
* @link http://code.google.com/apis/analytics/docs/gaJS/gaJSApiEcommerce.html#_gat.GA_Tracker_._addTrans
|
1978 |
+
* @link http://code.google.com/apis/analytics/docs/gaJS/gaJSApiEcommerce.html#_gat.GA_Tracker_._addItem
|
1979 |
+
* @link http://code.google.com/apis/analytics/docs/gaJS/gaJSApiEcommerce.html#_gat.GA_Tracker_._trackTrans
|
1980 |
+
*
|
1981 |
+
* @param \UnitedPrototype\GoogleAnalytics\Transaction $transaction
|
1982 |
+
* @param \UnitedPrototype\GoogleAnalytics\Session $session
|
1983 |
+
* @param \UnitedPrototype\GoogleAnalytics\Visitor $visitor
|
1984 |
+
*/
|
1985 |
+
public function trackTransaction(Transaction $transaction, Session $session, Visitor $visitor) {
|
1986 |
+
// Ensure that all required parameters are set
|
1987 |
+
$transaction->validate();
|
1988 |
+
|
1989 |
+
$request = new TransactionRequest(static::$config);
|
1990 |
+
$request->setTransaction($transaction);
|
1991 |
+
$request->setSession($session);
|
1992 |
+
$request->setVisitor($visitor);
|
1993 |
+
$request->setTracker($this);
|
1994 |
+
$request->fire();
|
1995 |
+
|
1996 |
+
// Every item gets a separate request,
|
1997 |
+
// see http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/v4/Tracker.as#312
|
1998 |
+
foreach($transaction->getItems() as $item) {
|
1999 |
+
// Ensure that all required parameters are set
|
2000 |
+
$item->validate();
|
2001 |
+
|
2002 |
+
$request = new ItemRequest(static::$config);
|
2003 |
+
$request->setItem($item);
|
2004 |
+
$request->setSession($session);
|
2005 |
+
$request->setVisitor($visitor);
|
2006 |
+
$request->setTracker($this);
|
2007 |
+
$request->fire();
|
2008 |
+
}
|
2009 |
+
}
|
2010 |
+
|
2011 |
+
/**
|
2012 |
+
* Equivalent of _trackSocial() in GA Javascript client.
|
2013 |
+
*
|
2014 |
+
* @link http://code.google.com/apis/analytics/docs/tracking/gaTrackingSocial.html#settingUp
|
2015 |
+
* @param \UnitedPrototype\GoogleAnalytics\SocialInteraction $socialInteraction
|
2016 |
+
* @param \UnitedPrototype\GoogleAnalytics\Page $page
|
2017 |
+
* @param \UnitedPrototype\GoogleAnalytics\Session $session
|
2018 |
+
* @param \UnitedPrototype\GoogleAnalytics\Visitor $visitor
|
2019 |
+
*/
|
2020 |
+
public function trackSocial(SocialInteraction $socialInteraction, Page $page, Session $session, Visitor $visitor) {
|
2021 |
+
$request = new SocialInteractionRequest(static::$config);
|
2022 |
+
$request->setSocialInteraction($socialInteraction);
|
2023 |
+
$request->setPage($page);
|
2024 |
+
$request->setSession($session);
|
2025 |
+
$request->setVisitor($visitor);
|
2026 |
+
$request->setTracker($this);
|
2027 |
+
$request->fire();
|
2028 |
+
}
|
2029 |
+
|
2030 |
+
/**
|
2031 |
+
* For internal use only. Will trigger an error according to the current
|
2032 |
+
* Config::$errorSeverity setting.
|
2033 |
+
*
|
2034 |
+
* @see Config::$errorSeverity
|
2035 |
+
* @param string $message
|
2036 |
+
* @param string $method
|
2037 |
+
*/
|
2038 |
+
public static function _raiseError($message, $method) {
|
2039 |
+
$method = str_replace(__NAMESPACE__ . '\\', '', $method);
|
2040 |
+
$message = $method . '(): ' . $message;
|
2041 |
+
|
2042 |
+
$errorSeverity = isset(static::$config) ? static::$config->getErrorSeverity() : Config::ERROR_SEVERITY_EXCEPTIONS;
|
2043 |
+
|
2044 |
+
switch($errorSeverity) {
|
2045 |
+
case Config::ERROR_SEVERITY_SILENCE:
|
2046 |
+
// Do nothing
|
2047 |
+
break;
|
2048 |
+
case Config::ERROR_SEVERITY_WARNINGS:
|
2049 |
+
trigger_error($message, E_USER_WARNING);
|
2050 |
+
break;
|
2051 |
+
case Config::ERROR_SEVERITY_EXCEPTIONS:
|
2052 |
+
throw new Exception($message);
|
2053 |
+
break;
|
2054 |
+
}
|
2055 |
+
}
|
2056 |
+
|
2057 |
+
}
|
2058 |
+
|
2059 |
+
}
|
2060 |
+
|
2061 |
+
|
2062 |
+
|
2063 |
+
|
2064 |
+
/**
|
2065 |
+
* Generic Server-Side Google Analytics PHP Client
|
2066 |
+
*
|
2067 |
+
* This library is free software; you can redistribute it and/or
|
2068 |
+
* modify it under the terms of the GNU Lesser General Public
|
2069 |
+
* License (LGPL) as published by the Free Software Foundation; either
|
2070 |
+
* version 3 of the License, or (at your option) any later version.
|
2071 |
+
*
|
2072 |
+
* This library is distributed in the hope that it will be useful,
|
2073 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2074 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2075 |
+
* Lesser General Public License for more details.
|
2076 |
+
*
|
2077 |
+
* You should have received a copy of the GNU Lesser General Public
|
2078 |
+
* License along with this library; if not, write to the Free Software
|
2079 |
+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
2080 |
+
*
|
2081 |
+
* Google Analytics is a registered trademark of Google Inc.
|
2082 |
+
*
|
2083 |
+
* @link http://code.google.com/p/php-ga
|
2084 |
+
*
|
2085 |
+
* @license http://www.gnu.org/licenses/lgpl.html
|
2086 |
+
* @author Thomas Bachem <tb@unitedprototype.com>
|
2087 |
+
* @copyright Copyright (c) 2010 United Prototype GmbH (http://unitedprototype.com)
|
2088 |
+
*/
|
2089 |
+
|
2090 |
+
namespace UnitedPrototype\GoogleAnalytics{
|
2091 |
+
|
2092 |
+
/**
|
2093 |
+
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/ecommerce/Transaction.as
|
2094 |
+
*/
|
2095 |
+
class Transaction {
|
2096 |
+
|
2097 |
+
/**
|
2098 |
+
* Order ID, e.g. "a2343898", will be mapped to "utmtid" parameter
|
2099 |
+
*
|
2100 |
+
* @see Internals\ParameterHolder::$utmtid
|
2101 |
+
* @var string
|
2102 |
+
*/
|
2103 |
+
protected $orderId;
|
2104 |
+
|
2105 |
+
/**
|
2106 |
+
* Affiliation, Will be mapped to "utmtst" parameter
|
2107 |
+
*
|
2108 |
+
* @see Internals\ParameterHolder::$utmtst
|
2109 |
+
* @var string
|
2110 |
+
*/
|
2111 |
+
protected $affiliation;
|
2112 |
+
|
2113 |
+
/**
|
2114 |
+
* Total Cost, will be mapped to "utmtto" parameter
|
2115 |
+
*
|
2116 |
+
* @see Internals\ParameterHolder::$utmtto
|
2117 |
+
* @var float
|
2118 |
+
*/
|
2119 |
+
protected $total;
|
2120 |
+
|
2121 |
+
/**
|
2122 |
+
* Tax Cost, will be mapped to "utmttx" parameter
|
2123 |
+
*
|
2124 |
+
* @see Internals\ParameterHolder::$utmttx
|
2125 |
+
* @var float
|
2126 |
+
*/
|
2127 |
+
protected $tax;
|
2128 |
+
|
2129 |
+
/**
|
2130 |
+
* Shipping Cost, values as for unit and price, e.g. 3.95, will be mapped to
|
2131 |
+
* "utmtsp" parameter
|
2132 |
+
*
|
2133 |
+
* @see Internals\ParameterHolder::$utmtsp
|
2134 |
+
* @var float
|
2135 |
+
*/
|
2136 |
+
protected $shipping;
|
2137 |
+
|
2138 |
+
/**
|
2139 |
+
* Billing City, e.g. "Cologne", will be mapped to "utmtci" parameter
|
2140 |
+
*
|
2141 |
+
* @see Internals\ParameterHolder::$utmtci
|
2142 |
+
* @var string
|
2143 |
+
*/
|
2144 |
+
protected $city;
|
2145 |
+
|
2146 |
+
/**
|
2147 |
+
* Billing Region, e.g. "North Rhine-Westphalia", will be mapped to "utmtrg" parameter
|
2148 |
+
*
|
2149 |
+
* @see Internals\ParameterHolder::$utmtrg
|
2150 |
+
* @var string
|
2151 |
+
*/
|
2152 |
+
protected $region;
|
2153 |
+
|
2154 |
+
/**
|
2155 |
+
* Billing Country, e.g. "Germany", will be mapped to "utmtco" parameter
|
2156 |
+
*
|
2157 |
+
* @see Internals\ParameterHolder::$utmtco
|
2158 |
+
* @var string
|
2159 |
+
*/
|
2160 |
+
protected $country;
|
2161 |
+
|
2162 |
+
/**
|
2163 |
+
* @see Transaction::addItem()
|
2164 |
+
* @var \UnitedPrototype\GoogleAnalytics\Item[]
|
2165 |
+
*/
|
2166 |
+
protected $items = array();
|
2167 |
+
|
2168 |
+
|
2169 |
+
public function validate() {
|
2170 |
+
if(!$this->items) {
|
2171 |
+
Tracker::_raiseError('Transactions need to consist of at least one item.', __METHOD__);
|
2172 |
+
}
|
2173 |
+
}
|
2174 |
+
|
2175 |
+
/**
|
2176 |
+
* @link http://code.google.com/apis/analytics/docs/gaJS/gaJSApiEcommerce.html#_gat.GA_Tracker_._addItem
|
2177 |
+
* @param \UnitedPrototype\GoogleAnalytics\Item $item
|
2178 |
+
*/
|
2179 |
+
public function addItem(Item $item) {
|
2180 |
+
// Associated items inherit the transaction's order ID
|
2181 |
+
$item->setOrderId($this->orderId);
|
2182 |
+
|
2183 |
+
$sku = $item->getSku();
|
2184 |
+
$this->items[$sku] = $item;
|
2185 |
+
}
|
2186 |
+
|
2187 |
+
/**
|
2188 |
+
* @return \UnitedPrototype\GoogleAnalytics\Item[]
|
2189 |
+
*/
|
2190 |
+
public function getItems() {
|
2191 |
+
return $this->items;
|
2192 |
+
}
|
2193 |
+
|
2194 |
+
/**
|
2195 |
+
* @return string
|
2196 |
+
*/
|
2197 |
+
public function getOrderId() {
|
2198 |
+
return $this->orderId;
|
2199 |
+
}
|
2200 |
+
|
2201 |
+
/**
|
2202 |
+
* @param string $orderId
|
2203 |
+
*/
|
2204 |
+
public function setOrderId($orderId) {
|
2205 |
+
$this->orderId = $orderId;
|
2206 |
+
|
2207 |
+
// Update order IDs of all associated items too
|
2208 |
+
foreach($this->items as $item) {
|
2209 |
+
$item->setOrderId($orderId);
|
2210 |
+
}
|
2211 |
+
}
|
2212 |
+
|
2213 |
+
/**
|
2214 |
+
* @return string
|
2215 |
+
*/
|
2216 |
+
public function getAffiliation() {
|
2217 |
+
return $this->affiliation;
|
2218 |
+
}
|
2219 |
+
|
2220 |
+
/**
|
2221 |
+
* @param string $affiliation
|
2222 |
+
*/
|
2223 |
+
public function setAffiliation($affiliation) {
|
2224 |
+
$this->affiliation = $affiliation;
|
2225 |
+
}
|
2226 |
+
|
2227 |
+
/**
|
2228 |
+
* @return float
|
2229 |
+
*/
|
2230 |
+
public function getTotal() {
|
2231 |
+
return $this->total;
|
2232 |
+
}
|
2233 |
+
|
2234 |
+
/**
|
2235 |
+
* @param float $total
|
2236 |
+
*/
|
2237 |
+
public function setTotal($total) {
|
2238 |
+
$this->total = $total;
|
2239 |
+
}
|
2240 |
+
|
2241 |
+
/**
|
2242 |
+
* @return float
|
2243 |
+
*/
|
2244 |
+
public function getTax() {
|
2245 |
+
return $this->tax;
|
2246 |
+
}
|
2247 |
+
|
2248 |
+
/**
|
2249 |
+
* @param float $tax
|
2250 |
+
*/
|
2251 |
+
public function setTax($tax) {
|
2252 |
+
$this->tax = $tax;
|
2253 |
+
}
|
2254 |
+
|
2255 |
+
/**
|
2256 |
+
* @return float
|
2257 |
+
*/
|
2258 |
+
public function getShipping() {
|
2259 |
+
return $this->shipping;
|
2260 |
+
}
|
2261 |
+
|
2262 |
+
/**
|
2263 |
+
* @param float $shipping
|
2264 |
+
*/
|
2265 |
+
public function setShipping($shipping) {
|
2266 |
+
$this->shipping = $shipping;
|
2267 |
+
}
|
2268 |
+
|
2269 |
+
/**
|
2270 |
+
* @return string
|
2271 |
+
*/
|
2272 |
+
public function getCity() {
|
2273 |
+
return $this->city;
|
2274 |
+
}
|
2275 |
+
|
2276 |
+
/**
|
2277 |
+
* @param string $city
|
2278 |
+
*/
|
2279 |
+
public function setCity($city) {
|
2280 |
+
$this->city = $city;
|
2281 |
+
}
|
2282 |
+
|
2283 |
+
/**
|
2284 |
+
* @return string
|
2285 |
+
*/
|
2286 |
+
public function getRegion() {
|
2287 |
+
return $this->region;
|
2288 |
+
}
|
2289 |
+
|
2290 |
+
/**
|
2291 |
+
* @param string $region
|
2292 |
+
*/
|
2293 |
+
public function setRegion($region) {
|
2294 |
+
$this->region = $region;
|
2295 |
+
}
|
2296 |
+
|
2297 |
+
/**
|
2298 |
+
* @return string
|
2299 |
+
*/
|
2300 |
+
public function getCountry() {
|
2301 |
+
return $this->country;
|
2302 |
+
}
|
2303 |
+
|
2304 |
+
/**
|
2305 |
+
* @param string $country
|
2306 |
+
*/
|
2307 |
+
public function setCountry($country) {
|
2308 |
+
$this->country = $country;
|
2309 |
+
}
|
2310 |
+
|
2311 |
+
}
|
2312 |
+
|
2313 |
+
}
|
2314 |
+
|
2315 |
+
|
2316 |
+
|
2317 |
+
|
2318 |
+
|
2319 |
+
|
2320 |
+
/**
|
2321 |
+
* Generic Server-Side Google Analytics PHP Client
|
2322 |
+
*
|
2323 |
+
* This library is free software; you can redistribute it and/or
|
2324 |
+
* modify it under the terms of the GNU Lesser General Public
|
2325 |
+
* License (LGPL) as published by the Free Software Foundation; either
|
2326 |
+
* version 3 of the License, or (at your option) any later version.
|
2327 |
+
*
|
2328 |
+
* This library is distributed in the hope that it will be useful,
|
2329 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2330 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2331 |
+
* Lesser General Public License for more details.
|
2332 |
+
*
|
2333 |
+
* You should have received a copy of the GNU Lesser General Public
|
2334 |
+
* License along with this library; if not, write to the Free Software
|
2335 |
+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
2336 |
+
*
|
2337 |
+
* Google Analytics is a registered trademark of Google Inc.
|
2338 |
+
*
|
2339 |
+
* @link http://code.google.com/p/php-ga
|
2340 |
+
*
|
2341 |
+
* @license http://www.gnu.org/licenses/lgpl.html
|
2342 |
+
* @author Thomas Bachem <tb@unitedprototype.com>
|
2343 |
+
* @copyright Copyright (c) 2010 United Prototype GmbH (http://unitedprototype.com)
|
2344 |
+
*/
|
2345 |
+
|
2346 |
+
namespace UnitedPrototype\GoogleAnalytics{
|
2347 |
+
|
2348 |
+
use UnitedPrototype\GoogleAnalytics\Internals\Util;
|
2349 |
+
|
2350 |
+
use DateTime;
|
2351 |
+
|
2352 |
+
/**
|
2353 |
+
* You should serialize this object and store it in the user database to keep it
|
2354 |
+
* persistent for the same user permanently (similar to the "__umta" cookie of
|
2355 |
+
* the GA Javascript client).
|
2356 |
+
*/
|
2357 |
+
class Visitor {
|
2358 |
+
|
2359 |
+
/**
|
2360 |
+
* Unique user ID, will be part of the "__utma" cookie parameter
|
2361 |
+
*
|
2362 |
+
* @see Internals\ParameterHolder::$__utma
|
2363 |
+
* @var int
|
2364 |
+
*/
|
2365 |
+
protected $uniqueId;
|
2366 |
+
|
2367 |
+
/**
|
2368 |
+
* Time of the very first visit of this user, will be part of the "__utma"
|
2369 |
+
* cookie parameter
|
2370 |
+
*
|
2371 |
+
* @see Internals\ParameterHolder::$__utma
|
2372 |
+
* @var DateTime
|
2373 |
+
*/
|
2374 |
+
protected $firstVisitTime;
|
2375 |
+
|
2376 |
+
/**
|
2377 |
+
* Time of the previous visit of this user, will be part of the "__utma"
|
2378 |
+
* cookie parameter
|
2379 |
+
*
|
2380 |
+
* @see Internals\ParameterHolder::$__utma
|
2381 |
+
* @see addSession
|
2382 |
+
* @var DateTime
|
2383 |
+
*/
|
2384 |
+
protected $previousVisitTime;
|
2385 |
+
|
2386 |
+
/**
|
2387 |
+
* Time of the current visit of this user, will be part of the "__utma"
|
2388 |
+
* cookie parameter
|
2389 |
+
*
|
2390 |
+
* @see Internals\ParameterHolder::$__utma
|
2391 |
+
* @see addSession
|
2392 |
+
* @var DateTime
|
2393 |
+
*/
|
2394 |
+
protected $currentVisitTime;
|
2395 |
+
|
2396 |
+
/**
|
2397 |
+
* Amount of total visits by this user, will be part of the "__utma"
|
2398 |
+
* cookie parameter
|
2399 |
+
*
|
2400 |
+
* @see Internals\ParameterHolder::$__utma
|
2401 |
+
* @var int
|
2402 |
+
*/
|
2403 |
+
protected $visitCount;
|
2404 |
+
|
2405 |
+
/**
|
2406 |
+
* IP Address of the end user, e.g. "123.123.123.123", will be mapped to "utmip" parameter
|
2407 |
+
* and "X-Forwarded-For" request header
|
2408 |
+
*
|
2409 |
+
* @see Internals\ParameterHolder::$utmip
|
2410 |
+
* @see Internals\Request\HttpRequest::$xForwardedFor
|
2411 |
+
* @var string
|
2412 |
+
*/
|
2413 |
+
protected $ipAddress;
|
2414 |
+
|
2415 |
+
/**
|
2416 |
+
* User agent string of the end user, will be mapped to "User-Agent" request header
|
2417 |
+
*
|
2418 |
+
* @see Internals\Request\HttpRequest::$userAgent
|
2419 |
+
* @var string
|
2420 |
+
*/
|
2421 |
+
protected $userAgent;
|
2422 |
+
|
2423 |
+
/**
|
2424 |
+
* Locale string (country part optional), e.g. "de-DE", will be mapped to "utmul" parameter
|
2425 |
+
*
|
2426 |
+
* @see Internals\ParameterHolder::$utmul
|
2427 |
+
* @var string
|
2428 |
+
*/
|
2429 |
+
protected $locale;
|
2430 |
+
|
2431 |
+
/**
|
2432 |
+
* Visitor's Flash version, e.g. "9.0 r28", will be maped to "utmfl" parameter
|
2433 |
+
*
|
2434 |
+
* @see Internals\ParameterHolder::$utmfl
|
2435 |
+
* @var string
|
2436 |
+
*/
|
2437 |
+
protected $flashVersion;
|
2438 |
+
|
2439 |
+
/**
|
2440 |
+
* Visitor's Java support, will be mapped to "utmje" parameter
|
2441 |
+
*
|
2442 |
+
* @see Internals\ParameterHolder::$utmje
|
2443 |
+
* @var bool
|
2444 |
+
*/
|
2445 |
+
protected $javaEnabled;
|
2446 |
+
|
2447 |
+
/**
|
2448 |
+
* Visitor's screen color depth, e.g. 32, will be mapped to "utmsc" parameter
|
2449 |
+
*
|
2450 |
+
* @see Internals\ParameterHolder::$utmsc
|
2451 |
+
* @var string
|
2452 |
+
*/
|
2453 |
+
protected $screenColorDepth;
|
2454 |
+
|
2455 |
+
/**
|
2456 |
+
* Visitor's screen resolution, e.g. "1024x768", will be mapped to "utmsr" parameter
|
2457 |
+
*
|
2458 |
+
* @see Internals\ParameterHolder::$utmsr
|
2459 |
+
* @var string
|
2460 |
+
*/
|
2461 |
+
protected $screenResolution;
|
2462 |
+
|
2463 |
+
|
2464 |
+
/**
|
2465 |
+
* Creates a new visitor without any previous visit information.
|
2466 |
+
*/
|
2467 |
+
public function __construct() {
|
2468 |
+
// ga.js sets all three timestamps to now for new visitors, so we do the same
|
2469 |
+
$now = new DateTime();
|
2470 |
+
$this->setFirstVisitTime($now);
|
2471 |
+
$this->setPreviousVisitTime($now);
|
2472 |
+
$this->setCurrentVisitTime($now);
|
2473 |
+
|
2474 |
+
$this->setVisitCount(1);
|
2475 |
+
}
|
2476 |
+
|
2477 |
+
/**
|
2478 |
+
* Will extract information for the "uniqueId", "firstVisitTime", "previousVisitTime",
|
2479 |
+
* "currentVisitTime" and "visitCount" properties from the given "__utma" cookie
|
2480 |
+
* value.
|
2481 |
+
*
|
2482 |
+
* @see Internals\ParameterHolder::$__utma
|
2483 |
+
* @see Internals\Request\Request::buildCookieParameters()
|
2484 |
+
* @param string $value
|
2485 |
+
* @return $this
|
2486 |
+
*/
|
2487 |
+
public function fromUtma($value) {
|
2488 |
+
$parts = explode('.', $value);
|
2489 |
+
if(count($parts) != 6) {
|
2490 |
+
Tracker::_raiseError('The given "__utma" cookie value is invalid.', __METHOD__);
|
2491 |
+
return $this;
|
2492 |
+
}
|
2493 |
+
|
2494 |
+
$this->setUniqueId($parts[1]);
|
2495 |
+
$this->setFirstVisitTime(new DateTime('@' . $parts[2]));
|
2496 |
+
$this->setPreviousVisitTime(new DateTime('@' . $parts[3]));
|
2497 |
+
$this->setCurrentVisitTime(new DateTime('@' . $parts[4]));
|
2498 |
+
$this->setVisitCount($parts[5]);
|
2499 |
+
|
2500 |
+
// Allow chaining
|
2501 |
+
return $this;
|
2502 |
+
}
|
2503 |
+
|
2504 |
+
/**
|
2505 |
+
* Will extract information for the "ipAddress", "userAgent" and "locale" properties
|
2506 |
+
* from the given $_SERVER variable.
|
2507 |
+
*
|
2508 |
+
* @param array $value
|
2509 |
+
* @return $this
|
2510 |
+
*/
|
2511 |
+
public function fromServerVar(array $value) {
|
2512 |
+
if(!empty($value['REMOTE_ADDR'])) {
|
2513 |
+
$ip = null;
|
2514 |
+
foreach(array('X_FORWARDED_FOR', 'REMOTE_ADDR') as $key) {
|
2515 |
+
if(!empty($value[$key]) && !$ip) {
|
2516 |
+
$ips = explode(',', $value[$key]);
|
2517 |
+
$ip = trim($ips[(count($ips) - 1)]);
|
2518 |
+
|
2519 |
+
// Double-check if the address has a valid format
|
2520 |
+
if(!preg_match('/^[\d+]{1,3}\.[\d+]{1,3}\.[\d+]{1,3}\.[\d+]{1,3}$/i', $ip)) {
|
2521 |
+
$ip = null;
|
2522 |
+
}
|
2523 |
+
// Exclude private IP address ranges
|
2524 |
+
if(preg_match('#^(?:127\.0\.0\.1|10\.|192\.168\.|172\.(?:1[6-9]|2[0-9]|3[0-1])\.)#', $ip)) {
|
2525 |
+
$ip = null;
|
2526 |
+
}
|
2527 |
+
}
|
2528 |
+
}
|
2529 |
+
|
2530 |
+
if($ip) {
|
2531 |
+
$this->setIpAddress($ip);
|
2532 |
+
}
|
2533 |
+
}
|
2534 |
+
|
2535 |
+
if(!empty($value['HTTP_USER_AGENT'])) {
|
2536 |
+
$this->setUserAgent($value['HTTP_USER_AGENT']);
|
2537 |
+
}
|
2538 |
+
|
2539 |
+
if(!empty($value['HTTP_ACCEPT_LANGUAGE'])) {
|
2540 |
+
$parsedLocales = array();
|
2541 |
+
if(preg_match_all('/(^|\s*,\s*)([a-zA-Z]{1,8}(-[a-zA-Z]{1,8})*)\s*(;\s*q\s*=\s*(1(\.0{0,3})?|0(\.[0-9]{0,3})))?/i', $value['HTTP_ACCEPT_LANGUAGE'], $matches)) {
|
2542 |
+
$matches[2] = array_map(function($part) { return str_replace('-', '_', $part); }, $matches[2]);
|
2543 |
+
$matches[5] = array_map(function($part) { return $part === '' ? 1 : $part; }, $matches[5]);
|
2544 |
+
$parsedLocales = array_combine($matches[2], $matches[5]);
|
2545 |
+
arsort($parsedLocales, SORT_NUMERIC);
|
2546 |
+
$parsedLocales = array_keys($parsedLocales);
|
2547 |
+
}
|
2548 |
+
|
2549 |
+
if($parsedLocales) {
|
2550 |
+
$this->setLocale($parsedLocales[0]);
|
2551 |
+
}
|
2552 |
+
}
|
2553 |
+
|
2554 |
+
// Allow chaining
|
2555 |
+
return $this;
|
2556 |
+
}
|
2557 |
+
|
2558 |
+
/**
|
2559 |
+
* Generates a hashed value from user-specific properties.
|
2560 |
+
*
|
2561 |
+
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/v4/Tracker.as#542
|
2562 |
+
* @return int
|
2563 |
+
*/
|
2564 |
+
protected function generateHash() {
|
2565 |
+
// TODO: Emulate orginal Google Analytics client library generation more closely
|
2566 |
+
$string = $this->userAgent;
|
2567 |
+
$string .= $this->screenResolution . $this->screenColorDepth;
|
2568 |
+
return Util::generateHash($string);
|
2569 |
+
}
|
2570 |
+
|
2571 |
+
/**
|
2572 |
+
* Generates a unique user ID from the current user-specific properties.
|
2573 |
+
*
|
2574 |
+
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/v4/Tracker.as#563
|
2575 |
+
* @return int
|
2576 |
+
*/
|
2577 |
+
protected function generateUniqueId() {
|
2578 |
+
// There seems to be an error in the gaforflash code, so we take the formula
|
2579 |
+
// from http://xahlee.org/js/google_analytics_tracker_2010-07-01_expanded.js line 711
|
2580 |
+
// instead ("&" instead of "*")
|
2581 |
+
return ((Util::generate32bitRandom() ^ $this->generateHash()) & 0x7fffffff);
|
2582 |
+
}
|
2583 |
+
|
2584 |
+
/**
|
2585 |
+
* @see generateUniqueId
|
2586 |
+
* @param int $value
|
2587 |
+
*/
|
2588 |
+
public function setUniqueId($value) {
|
2589 |
+
if($value < 0 || $value > 0x7fffffff) {
|
2590 |
+
Tracker::_raiseError('Visitor unique ID has to be a 32-bit integer between 0 and ' . 0x7fffffff . '.', __METHOD__);
|
2591 |
+
}
|
2592 |
+
|
2593 |
+
$this->uniqueId = (int)$value;
|
2594 |
+
}
|
2595 |
+
|
2596 |
+
/**
|
2597 |
+
* Will be generated on first call (if not set already) to include as much
|
2598 |
+
* user-specific information as possible.
|
2599 |
+
*
|
2600 |
+
* @return int
|
2601 |
+
*/
|
2602 |
+
public function getUniqueId() {
|
2603 |
+
if($this->uniqueId === null) {
|
2604 |
+
$this->uniqueId = $this->generateUniqueId();
|
2605 |
+
}
|
2606 |
+
return $this->uniqueId;
|
2607 |
+
}
|
2608 |
+
|
2609 |
+
/**
|
2610 |
+
* Updates the "previousVisitTime", "currentVisitTime" and "visitCount"
|
2611 |
+
* fields based on the given session object.
|
2612 |
+
*
|
2613 |
+
* @param Session $session
|
2614 |
+
*/
|
2615 |
+
public function addSession(Session $session) {
|
2616 |
+
$startTime = $session->getStartTime();
|
2617 |
+
if($startTime != $this->currentVisitTime) {
|
2618 |
+
$this->previousVisitTime = $this->currentVisitTime;
|
2619 |
+
$this->currentVisitTime = $startTime;
|
2620 |
+
++$this->visitCount;
|
2621 |
+
}
|
2622 |
+
}
|
2623 |
+
|
2624 |
+
/**
|
2625 |
+
* @param DateTime $value
|
2626 |
+
*/
|
2627 |
+
public function setFirstVisitTime(DateTime $value) {
|
2628 |
+
$this->firstVisitTime = $value;
|
2629 |
+
}
|
2630 |
+
|
2631 |
+
/**
|
2632 |
+
* @return DateTime
|
2633 |
+
*/
|
2634 |
+
public function getFirstVisitTime() {
|
2635 |
+
return $this->firstVisitTime;
|
2636 |
+
}
|
2637 |
+
|
2638 |
+
/**
|
2639 |
+
* @param DateTime $value
|
2640 |
+
*/
|
2641 |
+
public function setPreviousVisitTime(DateTime $value) {
|
2642 |
+
$this->previousVisitTime = $value;
|
2643 |
+
}
|
2644 |
+
|
2645 |
+
/**
|
2646 |
+
* @return DateTime
|
2647 |
+
*/
|
2648 |
+
public function getPreviousVisitTime() {
|
2649 |
+
return $this->previousVisitTime;
|
2650 |
+
}
|
2651 |
+
|
2652 |
+
/**
|
2653 |
+
* @param DateTime $value
|
2654 |
+
*/
|
2655 |
+
public function setCurrentVisitTime(DateTime $value) {
|
2656 |
+
$this->currentVisitTime = $value;
|
2657 |
+
}
|
2658 |
+
|
2659 |
+
/**
|
2660 |
+
* @return DateTime
|
2661 |
+
*/
|
2662 |
+
public function getCurrentVisitTime() {
|
2663 |
+
return $this->currentVisitTime;
|
2664 |
+
}
|
2665 |
+
|
2666 |
+
/**
|
2667 |
+
* @param int $value
|
2668 |
+
*/
|
2669 |
+
public function setVisitCount($value) {
|
2670 |
+
$this->visitCount = (int)$value;
|
2671 |
+
}
|
2672 |
+
|
2673 |
+
/**
|
2674 |
+
* @return int
|
2675 |
+
*/
|
2676 |
+
public function getVisitCount() {
|
2677 |
+
return $this->visitCount;
|
2678 |
+
}
|
2679 |
+
|
2680 |
+
/**
|
2681 |
+
* @param string $value
|
2682 |
+
*/
|
2683 |
+
public function setIpAddress($value) {
|
2684 |
+
$this->ipAddress = $value;
|
2685 |
+
}
|
2686 |
+
|
2687 |
+
/**
|
2688 |
+
* @return string
|
2689 |
+
*/
|
2690 |
+
public function getIpAddress() {
|
2691 |
+
return $this->ipAddress;
|
2692 |
+
}
|
2693 |
+
|
2694 |
+
/**
|
2695 |
+
* @param string $value
|
2696 |
+
*/
|
2697 |
+
public function setUserAgent($value) {
|
2698 |
+
$this->userAgent = $value;
|
2699 |
+
}
|
2700 |
+
|
2701 |
+
/**
|
2702 |
+
* @return string
|
2703 |
+
*/
|
2704 |
+
public function getUserAgent() {
|
2705 |
+
return $this->userAgent;
|
2706 |
+
}
|
2707 |
+
|
2708 |
+
/**
|
2709 |
+
* @param string $value
|
2710 |
+
*/
|
2711 |
+
public function setLocale($value) {
|
2712 |
+
$this->locale = $value;
|
2713 |
+
}
|
2714 |
+
|
2715 |
+
/**
|
2716 |
+
* @return string
|
2717 |
+
*/
|
2718 |
+
public function getLocale() {
|
2719 |
+
return $this->locale;
|
2720 |
+
}
|
2721 |
+
|
2722 |
+
/**
|
2723 |
+
* @param string $value
|
2724 |
+
*/
|
2725 |
+
public function setFlashVersion($value) {
|
2726 |
+
$this->flashVersion = $value;
|
2727 |
+
}
|
2728 |
+
|
2729 |
+
/**
|
2730 |
+
* @return string
|
2731 |
+
*/
|
2732 |
+
public function getFlashVersion() {
|
2733 |
+
return $this->flashVersion;
|
2734 |
+
}
|
2735 |
+
|
2736 |
+
/**
|
2737 |
+
* @param bool $value
|
2738 |
+
*/
|
2739 |
+
public function setJavaEnabled($value) {
|
2740 |
+
$this->javaEnabled = (bool)$value;
|
2741 |
+
}
|
2742 |
+
|
2743 |
+
/**
|
2744 |
+
* @return bool
|
2745 |
+
*/
|
2746 |
+
public function getJavaEnabled() {
|
2747 |
+
return $this->javaEnabled;
|
2748 |
+
}
|
2749 |
+
|
2750 |
+
/**
|
2751 |
+
* @param int $value
|
2752 |
+
*/
|
2753 |
+
public function setScreenColorDepth($value) {
|
2754 |
+
$this->screenColorDepth = (int)$value;
|
2755 |
+
}
|
2756 |
+
|
2757 |
+
/**
|
2758 |
+
* @return string
|
2759 |
+
*/
|
2760 |
+
public function getScreenColorDepth() {
|
2761 |
+
return $this->screenColorDepth;
|
2762 |
+
}
|
2763 |
+
|
2764 |
+
/**
|
2765 |
+
* @param string $value
|
2766 |
+
*/
|
2767 |
+
public function setScreenResolution($value) {
|
2768 |
+
$this->screenResolution = $value;
|
2769 |
+
}
|
2770 |
+
|
2771 |
+
/**
|
2772 |
+
* @return string
|
2773 |
+
*/
|
2774 |
+
public function getScreenResolution() {
|
2775 |
+
return $this->screenResolution;
|
2776 |
+
}
|
2777 |
+
|
2778 |
+
}
|
2779 |
+
}
|
2780 |
+
|
2781 |
+
|
2782 |
+
|
2783 |
+
|
2784 |
+
/**
|
2785 |
+
* Generic Server-Side Google Analytics PHP Client
|
2786 |
+
*
|
2787 |
+
* This library is free software; you can redistribute it and/or
|
2788 |
+
* modify it under the terms of the GNU Lesser General Public
|
2789 |
+
* License (LGPL) as published by the Free Software Foundation; either
|
2790 |
+
* version 3 of the License, or (at your option) any later version.
|
2791 |
+
*
|
2792 |
+
* This library is distributed in the hope that it will be useful,
|
2793 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2794 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2795 |
+
* Lesser General Public License for more details.
|
2796 |
+
*
|
2797 |
+
* You should have received a copy of the GNU Lesser General Public
|
2798 |
+
* License along with this library; if not, write to the Free Software
|
2799 |
+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
2800 |
+
*
|
2801 |
+
* Google Analytics is a registered trademark of Google Inc.
|
2802 |
+
*
|
2803 |
+
* @link http://code.google.com/p/php-ga
|
2804 |
+
*
|
2805 |
+
* @license http://www.gnu.org/licenses/lgpl.html
|
2806 |
+
* @author Thomas Bachem <tb@unitedprototype.com>
|
2807 |
+
* @copyright Copyright (c) 2010 United Prototype GmbH (http://unitedprototype.com)
|
2808 |
+
*/
|
2809 |
+
|
2810 |
+
namespace UnitedPrototype\GoogleAnalytics\Internals{
|
2811 |
+
|
2812 |
+
/**
|
2813 |
+
* This is nearly a 1:1 PHP port of the gaforflash X10 class code.
|
2814 |
+
*
|
2815 |
+
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/data/X10.as
|
2816 |
+
*/
|
2817 |
+
class X10 {
|
2818 |
+
|
2819 |
+
/**
|
2820 |
+
* @var array
|
2821 |
+
*/
|
2822 |
+
protected $projectData = array();
|
2823 |
+
|
2824 |
+
|
2825 |
+
/**
|
2826 |
+
* @var string
|
2827 |
+
*/
|
2828 |
+
protected $KEY = 'k';
|
2829 |
+
|
2830 |
+
/**
|
2831 |
+
* @var string
|
2832 |
+
*/
|
2833 |
+
protected $VALUE = 'v';
|
2834 |
+
|
2835 |
+
/**
|
2836 |
+
* @var array
|
2837 |
+
*/
|
2838 |
+
protected $SET = array('k', 'v');
|
2839 |
+
|
2840 |
+
/**
|
2841 |
+
* Opening delimiter for wrapping a set of values belonging to the same type.
|
2842 |
+
* @var string
|
2843 |
+
*/
|
2844 |
+
protected $DELIM_BEGIN = '(';
|
2845 |
+
|
2846 |
+
/**
|
2847 |
+
* Closing delimiter for wrapping a set of values belonging to the same type.
|
2848 |
+
* @var string
|
2849 |
+
*/
|
2850 |
+
protected $DELIM_END = ')';
|
2851 |
+
|
2852 |
+
/**
|
2853 |
+
* Delimiter between two consecutive num/value pairs.
|
2854 |
+
* @var string
|
2855 |
+
*/
|
2856 |
+
protected $DELIM_SET = '*';
|
2857 |
+
|
2858 |
+
/**
|
2859 |
+
* Delimiter between a num and its corresponding value.
|
2860 |
+
* @var string
|
2861 |
+
*/
|
2862 |
+
protected $DELIM_NUM_VALUE = '!';
|
2863 |
+
|
2864 |
+
/**
|
2865 |
+
* Mapping of escapable characters to their escaped forms.
|
2866 |
+
*
|
2867 |
+
* @var array
|
2868 |
+
*/
|
2869 |
+
protected $ESCAPE_CHAR_MAP = array(
|
2870 |
+
"'" => "'0",
|
2871 |
+
')' => "'1",
|
2872 |
+
'*' => "'2",
|
2873 |
+
'!' => "'3",
|
2874 |
+
);
|
2875 |
+
|
2876 |
+
/**
|
2877 |
+
* @var int
|
2878 |
+
*/
|
2879 |
+
protected $MINIMUM = 1;
|
2880 |
+
|
2881 |
+
|
2882 |
+
/**
|
2883 |
+
* @const int
|
2884 |
+
*/
|
2885 |
+
const OBJECT_KEY_NUM = 1;
|
2886 |
+
/**
|
2887 |
+
* @const int
|
2888 |
+
*/
|
2889 |
+
const TYPE_KEY_NUM = 2;
|
2890 |
+
/**
|
2891 |
+
* @const int
|
2892 |
+
*/
|
2893 |
+
const LABEL_KEY_NUM = 3;
|
2894 |
+
/**
|
2895 |
+
* @const int
|
2896 |
+
*/
|
2897 |
+
const VALUE_VALUE_NUM = 1;
|
2898 |
+
|
2899 |
+
|
2900 |
+
/**
|
2901 |
+
* @param int $projectId
|
2902 |
+
* @return bool
|
2903 |
+
*/
|
2904 |
+
protected function hasProject($projectId) {
|
2905 |
+
return isset($this->projectData[$projectId]);
|
2906 |
+
}
|
2907 |
+
|
2908 |
+
/**
|
2909 |
+
* @param int $projectId
|
2910 |
+
* @param int $num
|
2911 |
+
* @param mixed $value
|
2912 |
+
*/
|
2913 |
+
public function setKey($projectId, $num, $value) {
|
2914 |
+
$this->setInternal($projectId, $this->KEY, $num, $value);
|
2915 |
+
}
|
2916 |
+
|
2917 |
+
/**
|
2918 |
+
* @param int $projectId
|
2919 |
+
* @param int $num
|
2920 |
+
* @return mixed
|
2921 |
+
*/
|
2922 |
+
public function getKey($projectId, $num) {
|
2923 |
+
return $this->getInternal($projectId, $this->KEY, $num);
|
2924 |
+
}
|
2925 |
+
|
2926 |
+
/**
|
2927 |
+
* @param int $projectId
|
2928 |
+
*/
|
2929 |
+
public function clearKey($projectId) {
|
2930 |
+
$this->clearInternal($projectId, $this->KEY);
|
2931 |
+
}
|
2932 |
+
|
2933 |
+
/**
|
2934 |
+
* @param int $projectId
|
2935 |
+
* @param int $num
|
2936 |
+
* @param mixed $value
|
2937 |
+
*/
|
2938 |
+
public function setValue($projectId, $num, $value) {
|
2939 |
+
$this->setInternal($projectId, $this->VALUE, $num, $value);
|
2940 |
+
}
|
2941 |
+
|
2942 |
+
/**
|
2943 |
+
* @param int $projectId
|
2944 |
+
* @param int $num
|
2945 |
+
* @return mixed
|
2946 |
+
*/
|
2947 |
+
public function getValue($projectId, $num) {
|
2948 |
+
return $this->getInternal($projectId, $this->VALUE, $num);
|
2949 |
+
}
|
2950 |
+
|
2951 |
+
/**
|
2952 |
+
* @param int $projectId
|
2953 |
+
*/
|
2954 |
+
public function clearValue($projectId) {
|
2955 |
+
$this->clearInternal($projectId, $this->VALUE);
|
2956 |
+
}
|
2957 |
+
|
2958 |
+
/**
|
2959 |
+
* Shared internal implementation for setting an X10 data type.
|
2960 |
+
*
|
2961 |
+
* @param int $projectId
|
2962 |
+
* @param string $type
|
2963 |
+
* @param int $num
|
2964 |
+
* @param mixed $value
|
2965 |
+
*/
|
2966 |
+
protected function setInternal($projectId, $type, $num, $value) {
|
2967 |
+
if(!isset($this->projectData[$projectId])) {
|
2968 |
+
$this->projectData[$projectId] = array();
|
2969 |
+
}
|
2970 |
+
if(!isset($this->projectData[$projectId][$type])) {
|
2971 |
+
$this->projectData[$projectId][$type] = array();
|
2972 |
+
}
|
2973 |
+
|
2974 |
+
$this->projectData[$projectId][$type][$num] = $value;
|
2975 |
+
}
|
2976 |
+
|
2977 |
+
/**
|
2978 |
+
* Shared internal implementation for getting an X10 data type.
|
2979 |
+
*
|
2980 |
+
* @param int $projectId
|
2981 |
+
* @param string $type
|
2982 |
+
* @param int $num
|
2983 |
+
* @return mixed
|
2984 |
+
*/
|
2985 |
+
protected function getInternal($projectId, $type, $num) {
|
2986 |
+
if(isset($this->projectData[$projectId][$type][$num])) {
|
2987 |
+
return $this->projectData[$projectId][$type][$num];
|
2988 |
+
} else {
|
2989 |
+
return null;
|
2990 |
+
}
|
2991 |
+
}
|
2992 |
+
|
2993 |
+
/**
|
2994 |
+
* Shared internal implementation for clearing all X10 data of a type from a
|
2995 |
+
* certain project.
|
2996 |
+
*
|
2997 |
+
* @param int $projectId
|
2998 |
+
* @param string $type
|
2999 |
+
*/
|
3000 |
+
protected function clearInternal($projectId, $type) {
|
3001 |
+
if(isset($this->projectData[$projectId]) && isset($this->projectData[$projectId][$type])) {
|
3002 |
+
unset($this->projectData[$projectId][$type]);
|
3003 |
+
}
|
3004 |
+
}
|
3005 |
+
|
3006 |
+
/**
|
3007 |
+
* Escape X10 string values to remove ambiguity for special characters.
|
3008 |
+
*
|
3009 |
+
* @see X10::$escapeCharMap
|
3010 |
+
* @param string $value
|
3011 |
+
* @return string
|
3012 |
+
*/
|
3013 |
+
protected function escapeExtensibleValue($value) {
|
3014 |
+
$result = '';
|
3015 |
+
|
3016 |
+
$value = (string)$value;
|
3017 |
+
$length = strlen($value);
|
3018 |
+
for($i = 0; $i < $length; $i++) {
|
3019 |
+
$char = $value[$i];
|
3020 |
+
|
3021 |
+
if(isset($this->ESCAPE_CHAR_MAP[$char])) {
|
3022 |
+
$result .= $this->ESCAPE_CHAR_MAP[$char];
|
3023 |
+
} else {
|
3024 |
+
$result .= $char;
|
3025 |
+
}
|
3026 |
+
}
|
3027 |
+
|
3028 |
+
return $result;
|
3029 |
+
}
|
3030 |
+
|
3031 |
+
/**
|
3032 |
+
* Given a data array for a certain type, render its string encoding.
|
3033 |
+
*
|
3034 |
+
* @param array $data
|
3035 |
+
* @return string
|
3036 |
+
*/
|
3037 |
+
protected function renderDataType(array $data) {
|
3038 |
+
$result = array();
|
3039 |
+
|
3040 |
+
$lastI = 0;
|
3041 |
+
ksort($data, SORT_NUMERIC);
|
3042 |
+
foreach($data as $i => $entry) {
|
3043 |
+
if(isset($entry)) {
|
3044 |
+
$str = '';
|
3045 |
+
|
3046 |
+
// Check if we need to append the number. If the last number was
|
3047 |
+
// outputted, or if this is the assumed minimum, then we don't.
|
3048 |
+
if($i != $this->MINIMUM && $i - 1 != $lastI) {
|
3049 |
+
$str .= $i;
|
3050 |
+
$str .= $this->DELIM_NUM_VALUE;
|
3051 |
+
}
|
3052 |
+
|
3053 |
+
$str .= $this->escapeExtensibleValue($entry);
|
3054 |
+
$result[] = $str;
|
3055 |
+
}
|
3056 |
+
|
3057 |
+
$lastI = $i;
|
3058 |
+
}
|
3059 |
+
|
3060 |
+
return $this->DELIM_BEGIN . implode($this->DELIM_SET, $result) . $this->DELIM_END;
|
3061 |
+
}
|
3062 |
+
|
3063 |
+
/**
|
3064 |
+
* Given a project array, render its string encoding.
|
3065 |
+
*
|
3066 |
+
* @param array $project
|
3067 |
+
* @return string
|
3068 |
+
*/
|
3069 |
+
protected function renderProject(array $project) {
|
3070 |
+
$result = '';
|
3071 |
+
|
3072 |
+
// Do we need to output the type string? As an optimization we do not
|
3073 |
+
// output the type string if it's the first type, or if the previous
|
3074 |
+
// type was present.
|
3075 |
+
$needTypeQualifier = false;
|
3076 |
+
|
3077 |
+
$length = count($this->SET);
|
3078 |
+
for($i = 0; $i < $length; $i++) {
|
3079 |
+
if(isset($project[$this->SET[$i]])) {
|
3080 |
+
$data = $project[$this->SET[$i]];
|
3081 |
+
|
3082 |
+
if($needTypeQualifier) {
|
3083 |
+
$result .= $this->SET[$i];
|
3084 |
+
}
|
3085 |
+
$result .= $this->renderDataType($data);
|
3086 |
+
$needTypeQualifier = false;
|
3087 |
+
} else {
|
3088 |
+
$needTypeQualifier = true;
|
3089 |
+
}
|
3090 |
+
}
|
3091 |
+
|
3092 |
+
return $result;
|
3093 |
+
}
|
3094 |
+
|
3095 |
+
/**
|
3096 |
+
* Generates the URL parameter string for the current internal extensible data state.
|
3097 |
+
*
|
3098 |
+
* @return string
|
3099 |
+
*/
|
3100 |
+
public function renderUrlString() {
|
3101 |
+
$result = '';
|
3102 |
+
|
3103 |
+
foreach($this->projectData as $projectId => $project) {
|
3104 |
+
$result .= $projectId . $this->renderProject($project);
|
3105 |
+
}
|
3106 |
+
|
3107 |
+
return $result;
|
3108 |
+
}
|
3109 |
+
|
3110 |
+
}
|
3111 |
+
|
3112 |
+
}
|
3113 |
+
|
3114 |
+
|
3115 |
+
|
3116 |
+
|
3117 |
+
|
3118 |
+
/**
|
3119 |
+
* Generic Server-Side Google Analytics PHP Client
|
3120 |
+
*
|
3121 |
+
* This library is free software; you can redistribute it and/or
|
3122 |
+
* modify it under the terms of the GNU Lesser General Public
|
3123 |
+
* License (LGPL) as published by the Free Software Foundation; either
|
3124 |
+
* version 3 of the License, or (at your option) any later version.
|
3125 |
+
*
|
3126 |
+
* This library is distributed in the hope that it will be useful,
|
3127 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
3128 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
3129 |
+
* Lesser General Public License for more details.
|
3130 |
+
*
|
3131 |
+
* You should have received a copy of the GNU Lesser General Public
|
3132 |
+
* License along with this library; if not, write to the Free Software
|
3133 |
+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
3134 |
+
*
|
3135 |
+
* Google Analytics is a registered trademark of Google Inc.
|
3136 |
+
*
|
3137 |
+
* @link http://code.google.com/p/php-ga
|
3138 |
+
*
|
3139 |
+
* @license http://www.gnu.org/licenses/lgpl.html
|
3140 |
+
* @author Thomas Bachem <tb@unitedprototype.com>
|
3141 |
+
* @copyright Copyright (c) 2010 United Prototype GmbH (http://unitedprototype.com)
|
3142 |
+
*/
|
3143 |
+
|
3144 |
+
namespace UnitedPrototype\GoogleAnalytics\Internals{
|
3145 |
+
|
3146 |
+
/**
|
3147 |
+
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/core/Utils.as
|
3148 |
+
*/
|
3149 |
+
class Util {
|
3150 |
+
|
3151 |
+
/**
|
3152 |
+
* This class does only have public static methods, no instantiation necessary
|
3153 |
+
*/
|
3154 |
+
private function __construct() { }
|
3155 |
+
|
3156 |
+
|
3157 |
+
/**
|
3158 |
+
* Mimics Javascript's encodeURIComponent() function for consistency with the GA Javascript client.
|
3159 |
+
*
|
3160 |
+
* @param mixed $value
|
3161 |
+
* @return string
|
3162 |
+
*/
|
3163 |
+
public static function encodeUriComponent($value) {
|
3164 |
+
return static::convertToUriComponentEncoding(rawurlencode($value));
|
3165 |
+
}
|
3166 |
+
|
3167 |
+
/**
|
3168 |
+
* Here as a separate method so it can also be applied to e.g. a http_build_query() result.
|
3169 |
+
*
|
3170 |
+
* @link http://stackoverflow.com/questions/1734250/what-is-the-equivalent-of-javascripts-encodeuricomponent-in-php/1734255#1734255
|
3171 |
+
* @link http://devpro.it/examples/php_js_escaping.php
|
3172 |
+
*
|
3173 |
+
* @param string $encodedValue
|
3174 |
+
* @return string
|
3175 |
+
*/
|
3176 |
+
public static function convertToUriComponentEncoding($encodedValue) {
|
3177 |
+
return str_replace(array('%21', '%2A', '%27', '%28', '%29'), array('!', '*', "'", '(', ')'), $encodedValue);
|
3178 |
+
}
|
3179 |
+
|
3180 |
+
/**
|
3181 |
+
* Generates a 32bit random number.
|
3182 |
+
*
|
3183 |
+
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/core/Utils.as#33
|
3184 |
+
* @return int
|
3185 |
+
*/
|
3186 |
+
public static function generate32bitRandom() {
|
3187 |
+
return round((rand() / getrandmax()) * 0x7fffffff);
|
3188 |
+
}
|
3189 |
+
|
3190 |
+
/**
|
3191 |
+
* Generates a hash for input string.
|
3192 |
+
*
|
3193 |
+
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/core/Utils.as#44
|
3194 |
+
* @param string $string
|
3195 |
+
* @return int
|
3196 |
+
*/
|
3197 |
+
public static function generateHash($string) {
|
3198 |
+
$string = (string)$string;
|
3199 |
+
$hash = 1;
|
3200 |
+
|
3201 |
+
if($string !== null && $string !== '') {
|
3202 |
+
$hash = 0;
|
3203 |
+
|
3204 |
+
$length = strlen($string);
|
3205 |
+
for($pos = $length - 1; $pos >= 0; $pos--) {
|
3206 |
+
$current = ord($string[$pos]);
|
3207 |
+
$hash = (($hash << 6) & 0xfffffff) + $current + ($current << 14);
|
3208 |
+
$leftMost7 = $hash & 0xfe00000;
|
3209 |
+
if($leftMost7 != 0) {
|
3210 |
+
$hash ^= $leftMost7 >> 21;
|
3211 |
+
}
|
3212 |
+
}
|
3213 |
+
}
|
3214 |
+
|
3215 |
+
return $hash;
|
3216 |
+
}
|
3217 |
+
|
3218 |
+
}
|
3219 |
+
|
3220 |
+
}
|
3221 |
+
|
3222 |
+
|
3223 |
+
|
3224 |
+
|
3225 |
+
/**
|
3226 |
+
* Generic Server-Side Google Analytics PHP Client
|
3227 |
+
*
|
3228 |
+
* This library is free software; you can redistribute it and/or
|
3229 |
+
* modify it under the terms of the GNU Lesser General Public
|
3230 |
+
* License (LGPL) as published by the Free Software Foundation; either
|
3231 |
+
* version 3 of the License, or (at your option) any later version.
|
3232 |
+
*
|
3233 |
+
* This library is distributed in the hope that it will be useful,
|
3234 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
3235 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
3236 |
+
* Lesser General Public License for more details.
|
3237 |
+
*
|
3238 |
+
* You should have received a copy of the GNU Lesser General Public
|
3239 |
+
* License along with this library; if not, write to the Free Software
|
3240 |
+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
3241 |
+
*
|
3242 |
+
* Google Analytics is a registered trademark of Google Inc.
|
3243 |
+
*
|
3244 |
+
* @link http://code.google.com/p/php-ga
|
3245 |
+
*
|
3246 |
+
* @license http://www.gnu.org/licenses/lgpl.html
|
3247 |
+
* @author Thomas Bachem <tb@unitedprototype.com>
|
3248 |
+
* @copyright Copyright (c) 2010 United Prototype GmbH (http://unitedprototype.com)
|
3249 |
+
*/
|
3250 |
+
|
3251 |
+
namespace UnitedPrototype\GoogleAnalytics\Internals{
|
3252 |
+
|
3253 |
+
use UnitedPrototype\GoogleAnalytics\Tracker;
|
3254 |
+
|
3255 |
+
/**
|
3256 |
+
* This simple class is mainly meant to be a well-documented overview of all
|
3257 |
+
* possible GA tracking parameters.
|
3258 |
+
*
|
3259 |
+
* @link http://code.google.com/apis/analytics/docs/tracking/gaTrackingTroubleshooting.html#gifParameters
|
3260 |
+
*/
|
3261 |
+
class ParameterHolder {
|
3262 |
+
|
3263 |
+
// - - - - - - - - - - - - - - - - - General parameters - - - - - - - - - - - - - - - - -
|
3264 |
+
|
3265 |
+
/**
|
3266 |
+
* Google Analytics client version, e.g. "4.7.2"
|
3267 |
+
* @var string
|
3268 |
+
*/
|
3269 |
+
public $utmwv = Tracker::VERSION;
|
3270 |
+
|
3271 |
+
/**
|
3272 |
+
* Google Analytics account ID, e.g. "UA-1234567-8"
|
3273 |
+
* @var string
|
3274 |
+
*/
|
3275 |
+
public $utmac;
|
3276 |
+
|
3277 |
+
/**
|
3278 |
+
* Host Name, e.g. "www.example.com"
|
3279 |
+
* @var string
|
3280 |
+
*/
|
3281 |
+
public $utmhn;
|
3282 |
+
|
3283 |
+
/**
|
3284 |
+
* Indicates the type of request, which is one of null (for page), "event",
|
3285 |
+
* "tran", "item", "social", "var" (deprecated) or "error" (used by ga.js
|
3286 |
+
* for internal client error logging).
|
3287 |
+
* @var string
|
3288 |
+
*/
|
3289 |
+
public $utmt;
|
3290 |
+
|
3291 |
+
/**
|
3292 |
+
* Contains the amount of requests done in this session. Added in ga.js v4.9.2.
|
3293 |
+
* @var int
|
3294 |
+
*/
|
3295 |
+
public $utms;
|
3296 |
+
|
3297 |
+
/**
|
3298 |
+
* Unique ID (random number) generated for each GIF request
|
3299 |
+
* @var int
|
3300 |
+
*/
|
3301 |
+
public $utmn;
|
3302 |
+
|
3303 |
+
/**
|
3304 |
+
* Contains all cookie values, see below
|
3305 |
+
* @var string
|
3306 |
+
*/
|
3307 |
+
public $utmcc;
|
3308 |
+
|
3309 |
+
/**
|
3310 |
+
* Extensible Parameter, used for events and custom variables
|
3311 |
+
* @var string
|
3312 |
+
*/
|
3313 |
+
public $utme;
|
3314 |
+
|
3315 |
+
/**
|
3316 |
+
* Event "non-interaction" parameter. By default, the event hit will impact a visitor's bounce rate.
|
3317 |
+
* By setting this parameter to 1, this event hit will not be used in bounce rate calculations.
|
3318 |
+
* @link http://code.google.com/apis/analytics/docs/gaJS/gaJSApiEventTracking.html
|
3319 |
+
* @var int
|
3320 |
+
*/
|
3321 |
+
public $utmni;
|
3322 |
+
|
3323 |
+
/**
|
3324 |
+
* Whether to anonymize IP addresses within Google Analytics by stripping
|
3325 |
+
* the last IP address block, either null or 1
|
3326 |
+
* @var int
|
3327 |
+
*/
|
3328 |
+
public $aip;
|
3329 |
+
|
3330 |
+
/**
|
3331 |
+
* Used for GA-internal statistical client function usage and error tracking,
|
3332 |
+
* not implemented in php-ga as of now, but here for documentation completeness.
|
3333 |
+
* @link http://glucik.blogspot.com/2011/02/utmu-google-analytics-request-parameter.html
|
3334 |
+
* @var string
|
3335 |
+
*/
|
3336 |
+
public $utmu;
|
3337 |
+
|
3338 |
+
|
3339 |
+
// - - - - - - - - - - - - - - - - - Page parameters - - - - - - - - - - - - - - - - -
|
3340 |
+
|
3341 |
+
/**
|
3342 |
+
* Page request URI, e.g. "/path/page.html"
|
3343 |
+
* @var string
|
3344 |
+
*/
|
3345 |
+
public $utmp;
|
3346 |
+
|
3347 |
+
/**
|
3348 |
+
* Page title
|
3349 |
+
* @var string
|
3350 |
+
*/
|
3351 |
+
public $utmdt;
|
3352 |
+
|
3353 |
+
/**
|
3354 |
+
* Charset encoding (e.g. "UTF-8") or "-" as default
|
3355 |
+
* @var string
|
3356 |
+
*/
|
3357 |
+
public $utmcs = '-';
|
3358 |
+
|
3359 |
+
/**
|
3360 |
+
* Referer URL, e.g. "http://www.example.com/path/page.html", "-" as default
|
3361 |
+
* or "0" for internal referers
|
3362 |
+
* @var string
|
3363 |
+
*/
|
3364 |
+
public $utmr = '-';
|
3365 |
+
|
3366 |
+
|
3367 |
+
// - - - - - - - - - - - - - - - - - Visitor parameters - - - - - - - - - - - - - - - - -
|
3368 |
+
|
3369 |
+
/**
|
3370 |
+
* IP Address of the end user, e.g. "123.123.123.123", found in GA for Mobile examples,
|
3371 |
+
* but sadly seems to be ignored in normal GA use
|
3372 |
+
*
|
3373 |
+
* @link http://github.com/mptre/php-ga/blob/master/ga.php
|
3374 |
+
* @var string
|
3375 |
+
*/
|
3376 |
+
public $utmip;
|
3377 |
+
|
3378 |
+
/**
|
3379 |
+
* Visitor's locale string (all lower-case, country part optional), e.g. "de-de"
|
3380 |
+
* @var string
|
3381 |
+
*/
|
3382 |
+
public $utmul;
|
3383 |
+
|
3384 |
+
/**
|
3385 |
+
* Visitor's Flash version, e.g. "9.0 r28" or "-" as default
|
3386 |
+
* @var string
|
3387 |
+
*/
|
3388 |
+
public $utmfl = '-';
|
3389 |
+
|
3390 |
+
/**
|
3391 |
+
* Visitor's Java support, either 0 or 1 or "-" as default
|
3392 |
+
* @var int|string
|
3393 |
+
*/
|
3394 |
+
public $utmje = '-';
|
3395 |
+
|
3396 |
+
/**
|
3397 |
+
* Visitor's screen color depth, e.g. "32-bit"
|
3398 |
+
* @var string
|
3399 |
+
*/
|
3400 |
+
public $utmsc;
|
3401 |
+
|
3402 |
+
/**
|
3403 |
+
* Visitor's screen resolution, e.g. "1024x768"
|
3404 |
+
* @var string
|
3405 |
+
*/
|
3406 |
+
public $utmsr;
|
3407 |
+
|
3408 |
+
/**
|
3409 |
+
* Visitor tracking cookie parameter.
|
3410 |
+
*
|
3411 |
+
* This cookie is typically written to the browser upon the first visit to your site from that web browser.
|
3412 |
+
* If the cookie has been deleted by the browser operator, and the browser subsequently visits your site,
|
3413 |
+
* a new __utma cookie is written with a different unique ID.
|
3414 |
+
*
|
3415 |
+
* This cookie is used to determine unique visitors to your site and it is updated with each page view.
|
3416 |
+
* Additionally, this cookie is provided with a unique ID that Google Analytics uses to ensure both the
|
3417 |
+
* validity and accessibility of the cookie as an extra security measure.
|
3418 |
+
*
|
3419 |
+
* Expiration:
|
3420 |
+
* 2 years from set/update.
|
3421 |
+
*
|
3422 |
+
* Format:
|
3423 |
+
* __utma=<domainHash>.<uniqueId>.<firstTime>.<lastTime>.<currentTime>.<sessionCount>
|
3424 |
+
*
|
3425 |
+
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/data/UTMA.as
|
3426 |
+
* @var int
|
3427 |
+
*/
|
3428 |
+
public $__utma;
|
3429 |
+
|
3430 |
+
|
3431 |
+
// - - - - - - - - - - - - - - - - - Session parameters - - - - - - - - - - - - - - - - -
|
3432 |
+
|
3433 |
+
/**
|
3434 |
+
* Hit id for revenue per page tracking for AdSense, a random per-session ID
|
3435 |
+
*
|
3436 |
+
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/core/DocumentInfo.as#117
|
3437 |
+
* @var int
|
3438 |
+
*/
|
3439 |
+
public $utmhid;
|
3440 |
+
|
3441 |
+
/**
|
3442 |
+
* Session timeout cookie parameter.
|
3443 |
+
* Will never be sent with requests, but stays here for documentation completeness.
|
3444 |
+
*
|
3445 |
+
* This cookie is used to establish and continue a user session with your site.
|
3446 |
+
* When a user views a page on your site, the Google Analytics code attempts to update this cookie.
|
3447 |
+
* If it does not find the cookie, a new one is written and a new session is established.
|
3448 |
+
*
|
3449 |
+
* Each time a user visits a different page on your site, this cookie is updated to expire in 30 minutes,
|
3450 |
+
* thus continuing a single session for as long as user activity continues within 30-minute intervals.
|
3451 |
+
*
|
3452 |
+
* This cookie expires when a user pauses on a page on your site for longer than 30 minutes.
|
3453 |
+
* You can modify the default length of a user session with the setSessionTimeout() method.
|
3454 |
+
*
|
3455 |
+
* Expiration:
|
3456 |
+
* 30 minutes from set/update.
|
3457 |
+
*
|
3458 |
+
* Format:
|
3459 |
+
* __utmb=<domainHash>.<trackCount>.<token>.<lastTime>
|
3460 |
+
*
|
3461 |
+
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/data/UTMB.as
|
3462 |
+
* @var string
|
3463 |
+
*/
|
3464 |
+
public $__utmb;
|
3465 |
+
|
3466 |
+
/**
|
3467 |
+
* Session tracking cookie parameter.
|
3468 |
+
* Will never be sent with requests, but stays here for documentation completeness.
|
3469 |
+
*
|
3470 |
+
* This cookie operates in conjunction with the __utmb cookie to determine whether or not
|
3471 |
+
* to establish a new session for the user.
|
3472 |
+
* In particular, this cookie is not provided with an expiration date,
|
3473 |
+
* so it expires when the user exits the browser.
|
3474 |
+
*
|
3475 |
+
* Should a user visit your site, exit the browser and then return to your website within 30 minutes,
|
3476 |
+
* the absence of the __utmc cookie indicates that a new session needs to be established,
|
3477 |
+
* despite the fact that the __utmb cookie has not yet expired.
|
3478 |
+
*
|
3479 |
+
* Expiration:
|
3480 |
+
* Not set.
|
3481 |
+
*
|
3482 |
+
* Format:
|
3483 |
+
* __utmc=<domainHash>
|
3484 |
+
*
|
3485 |
+
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/data/UTMC.as
|
3486 |
+
* @var string
|
3487 |
+
*/
|
3488 |
+
public $__utmc;
|
3489 |
+
|
3490 |
+
|
3491 |
+
// - - - - - - - - - - - - - - - - - E-Commerce parameters - - - - - - - - - - - - - - - - -
|
3492 |
+
|
3493 |
+
/**
|
3494 |
+
* Product Code. This is the sku code for a given product, e.g. "989898ajssi"
|
3495 |
+
* @var string
|
3496 |
+
*/
|
3497 |
+
public $utmipc;
|
3498 |
+
|
3499 |
+
/**
|
3500 |
+
* Product Name, e.g. "T-Shirt"
|
3501 |
+
* @var string
|
3502 |
+
*/
|
3503 |
+
public $utmipn;
|
3504 |
+
|
3505 |
+
/**
|
3506 |
+
* Unit Price. Value is set to numbers only, e.g. 19.95
|
3507 |
+
* @var float
|
3508 |
+
*/
|
3509 |
+
public $utmipr;
|
3510 |
+
|
3511 |
+
/**
|
3512 |
+
* Unit Quantity, e.g. 4
|
3513 |
+
* @var int
|
3514 |
+
*/
|
3515 |
+
public $utmiqt;
|
3516 |
+
|
3517 |
+
/**
|
3518 |
+
* Variations on an item, e.g. "white", "black", "green" etc.
|
3519 |
+
* @var string
|
3520 |
+
*/
|
3521 |
+
public $utmiva;
|
3522 |
+
|
3523 |
+
/**
|
3524 |
+
* Order ID, e.g. "a2343898"
|
3525 |
+
* @var string
|
3526 |
+
*/
|
3527 |
+
public $utmtid;
|
3528 |
+
|
3529 |
+
/**
|
3530 |
+
* Affiliation
|
3531 |
+
* @var string
|
3532 |
+
*/
|
3533 |
+
public $utmtst;
|
3534 |
+
|
3535 |
+
/**
|
3536 |
+
* Total Cost, e.g. 20.00
|
3537 |
+
* @var float
|
3538 |
+
*/
|
3539 |
+
public $utmtto;
|
3540 |
+
|
3541 |
+
/**
|
3542 |
+
* Tax Cost, e.g. 4.23
|
3543 |
+
* @var float
|
3544 |
+
*/
|
3545 |
+
public $utmttx;
|
3546 |
+
|
3547 |
+
/**
|
3548 |
+
* Shipping Cost, e.g. 3.95
|
3549 |
+
* @var float
|
3550 |
+
*/
|
3551 |
+
public $utmtsp;
|
3552 |
+
|
3553 |
+
/**
|
3554 |
+
* Billing City, e.g. "Cologne"
|
3555 |
+
* @var string
|
3556 |
+
*/
|
3557 |
+
public $utmtci;
|
3558 |
+
|
3559 |
+
/**
|
3560 |
+
* Billing Region, e.g. "North Rhine-Westphalia"
|
3561 |
+
* @var string
|
3562 |
+
*/
|
3563 |
+
public $utmtrg;
|
3564 |
+
|
3565 |
+
/**
|
3566 |
+
* Billing Country, e.g. "Germany"
|
3567 |
+
* @var string
|
3568 |
+
*/
|
3569 |
+
public $utmtco;
|
3570 |
+
|
3571 |
+
|
3572 |
+
// - - - - - - - - - - - - - - - - - Campaign parameters - - - - - - - - - - - - - - - - -
|
3573 |
+
|
3574 |
+
/**
|
3575 |
+
* Starts a new campaign session. Either utmcn or utmcr is present on any given request,
|
3576 |
+
* but never both at the same time. Changes the campaign tracking data; but does not start
|
3577 |
+
* a new session. Either 1 or not set.
|
3578 |
+
*
|
3579 |
+
* Found in gaforflash but not in ga.js, so we do not use it, but it will stay here for
|
3580 |
+
* documentation completeness.
|
3581 |
+
*
|
3582 |
+
* @deprecated
|
3583 |
+
* @var int
|
3584 |
+
*/
|
3585 |
+
public $utmcn;
|
3586 |
+
|
3587 |
+
/**
|
3588 |
+
* Indicates a repeat campaign visit. This is set when any subsequent clicks occur on the
|
3589 |
+
* same link. Either utmcn or utmcr is present on any given request, but never both at the
|
3590 |
+
* same time. Either 1 or not set.
|
3591 |
+
*
|
3592 |
+
* Found in gaforflash but not in ga.js, so we do not use it, but it will stay here for
|
3593 |
+
* documentation completeness.
|
3594 |
+
*
|
3595 |
+
* @deprecated
|
3596 |
+
* @var int
|
3597 |
+
*/
|
3598 |
+
public $utmcr;
|
3599 |
+
|
3600 |
+
/**
|
3601 |
+
* Campaign ID, a.k.a. "utm_id" query parameter for ga.js
|
3602 |
+
* @var string
|
3603 |
+
*/
|
3604 |
+
public $utmcid;
|
3605 |
+
|
3606 |
+
/**
|
3607 |
+
* Source, a.k.a. "utm_source" query parameter for ga.js
|
3608 |
+
* @var string
|
3609 |
+
*/
|
3610 |
+
public $utmcsr;
|
3611 |
+
|
3612 |
+
/**
|
3613 |
+
* Google AdWords Click ID, a.k.a. "gclid" query parameter for ga.js
|
3614 |
+
* @var string
|
3615 |
+
*/
|
3616 |
+
public $utmgclid;
|
3617 |
+
|
3618 |
+
/**
|
3619 |
+
* Not known for sure, but expected to be a DoubleClick Ad Click ID.
|
3620 |
+
* @var string
|
3621 |
+
*/
|
3622 |
+
public $utmdclid;
|
3623 |
+
|
3624 |
+
/**
|
3625 |
+
* Name, a.k.a. "utm_campaign" query parameter for ga.js
|
3626 |
+
* @var string
|
3627 |
+
*/
|
3628 |
+
public $utmccn;
|
3629 |
+
|
3630 |
+
/**
|
3631 |
+
* Medium, a.k.a. "utm_medium" query parameter for ga.js
|
3632 |
+
* @var string
|
3633 |
+
*/
|
3634 |
+
public $utmcmd;
|
3635 |
+
|
3636 |
+
/**
|
3637 |
+
* Terms/Keywords, a.k.a. "utm_term" query parameter for ga.js
|
3638 |
+
* @var string
|
3639 |
+
*/
|
3640 |
+
public $utmctr;
|
3641 |
+
|
3642 |
+
/**
|
3643 |
+
* Ad Content Description, a.k.a. "utm_content" query parameter for ga.js
|
3644 |
+
* @var string
|
3645 |
+
*/
|
3646 |
+
public $utmcct;
|
3647 |
+
|
3648 |
+
/**
|
3649 |
+
* Unknown so far. Found in ga.js.
|
3650 |
+
* @var int
|
3651 |
+
*/
|
3652 |
+
public $utmcvr;
|
3653 |
+
|
3654 |
+
/**
|
3655 |
+
* Campaign tracking cookie parameter.
|
3656 |
+
*
|
3657 |
+
* This cookie stores the type of referral used by the visitor to reach your site,
|
3658 |
+
* whether via a direct method, a referring link, a website search, or a campaign such as an ad or an email link.
|
3659 |
+
*
|
3660 |
+
* It is used to calculate search engine traffic, ad campaigns and page navigation within your own site.
|
3661 |
+
* The cookie is updated with each page view to your site.
|
3662 |
+
*
|
3663 |
+
* Expiration:
|
3664 |
+
* 6 months from set/update.
|
3665 |
+
*
|
3666 |
+
* Format:
|
3667 |
+
* __utmz=<domainHash>.<campaignCreation>.<campaignSessions>.<responseCount>.<campaignTracking>
|
3668 |
+
*
|
3669 |
+
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/data/UTMZ.as
|
3670 |
+
* @var string
|
3671 |
+
*/
|
3672 |
+
public $__utmz;
|
3673 |
+
|
3674 |
+
|
3675 |
+
// - - - - - - - - - - - - - - - - - Social Tracking parameters - - - - - - - - - - - - - - - - -
|
3676 |
+
|
3677 |
+
/**
|
3678 |
+
* The network on which the action occurs (e.g. Facebook, Twitter).
|
3679 |
+
* @var string
|
3680 |
+
*/
|
3681 |
+
public $utmsn;
|
3682 |
+
|
3683 |
+
/**
|
3684 |
+
* The type of action that happens (e.g. Like, Send, Tweet).
|
3685 |
+
* @var string
|
3686 |
+
*/
|
3687 |
+
public $utmsa;
|
3688 |
+
|
3689 |
+
/**
|
3690 |
+
* The page URL from which the action occurred.
|
3691 |
+
* @var string
|
3692 |
+
*/
|
3693 |
+
public $utmsid;
|
3694 |
+
|
3695 |
+
|
3696 |
+
// - - - - - - - - - - - - - - - - - Google Website Optimizer (GWO) parameters - - - - - - - - - - - - - - - - -
|
3697 |
+
|
3698 |
+
// TODO: Implementation needed
|
3699 |
+
/**
|
3700 |
+
* Website Optimizer cookie parameter.
|
3701 |
+
*
|
3702 |
+
* This cookie is used by Website Optimizer and only set when Website Optimizer is used in combination
|
3703 |
+
* with GA. See the Google Website Optimizer Help Center for details.
|
3704 |
+
*
|
3705 |
+
* Expiration:
|
3706 |
+
* 2 years from set/update.
|
3707 |
+
*
|
3708 |
+
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/data/UTMX.as
|
3709 |
+
* @var string
|
3710 |
+
*/
|
3711 |
+
public $__utmx;
|
3712 |
+
|
3713 |
+
|
3714 |
+
// - - - - - - - - - - - - - - - - - Custom Variables parameters (deprecated) - - - - - - - - - - - - - - - - -
|
3715 |
+
|
3716 |
+
// TODO: Implementation needed?
|
3717 |
+
/**
|
3718 |
+
* Deprecated custom variables cookie parameter.
|
3719 |
+
*
|
3720 |
+
* This cookie parameter is no longer relevant as of migration from setVar() to
|
3721 |
+
* setCustomVar() and hence not supported by this library, but will stay here for
|
3722 |
+
* documentation completeness.
|
3723 |
+
*
|
3724 |
+
* The __utmv cookie passes the information provided via the setVar() method,
|
3725 |
+
* which you use to create a custom user segment.
|
3726 |
+
*
|
3727 |
+
* Expiration:
|
3728 |
+
* 2 years from set/update.
|
3729 |
+
*
|
3730 |
+
* Format:
|
3731 |
+
* __utmv=<domainHash>.<value>
|
3732 |
+
*
|
3733 |
+
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/data/UTMV.as
|
3734 |
+
* @deprecated
|
3735 |
+
* @var string
|
3736 |
+
*/
|
3737 |
+
public $__utmv;
|
3738 |
+
|
3739 |
+
|
3740 |
+
/**
|
3741 |
+
* Converts this parameter holder to a pure PHP array, filtering out all properties
|
3742 |
+
* prefixed with an underscore ("_").
|
3743 |
+
*
|
3744 |
+
* @return array
|
3745 |
+
*/
|
3746 |
+
public function toArray() {
|
3747 |
+
$array = array();
|
3748 |
+
foreach($this as $property => $value) {
|
3749 |
+
if($property[0] != '_') {
|
3750 |
+
$array[$property] = $value;
|
3751 |
+
}
|
3752 |
+
}
|
3753 |
+
return $array;
|
3754 |
+
}
|
3755 |
+
|
3756 |
+
}
|
3757 |
+
|
3758 |
+
}
|
3759 |
+
|
3760 |
+
|
3761 |
+
|
3762 |
+
|
3763 |
+
/**
|
3764 |
+
* Generic Server-Side Google Analytics PHP Client
|
3765 |
+
*
|
3766 |
+
* This library is free software; you can redistribute it and/or
|
3767 |
+
* modify it under the terms of the GNU Lesser General Public
|
3768 |
+
* License (LGPL) as published by the Free Software Foundation; either
|
3769 |
+
* version 3 of the License, or (at your option) any later version.
|
3770 |
+
*
|
3771 |
+
* This library is distributed in the hope that it will be useful,
|
3772 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
3773 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
3774 |
+
* Lesser General Public License for more details.
|
3775 |
+
*
|
3776 |
+
* You should have received a copy of the GNU Lesser General Public
|
3777 |
+
* License along with this library; if not, write to the Free Software
|
3778 |
+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
3779 |
+
*
|
3780 |
+
* Google Analytics is a registered trademark of Google Inc.
|
3781 |
+
*
|
3782 |
+
* @link http://code.google.com/p/php-ga
|
3783 |
+
*
|
3784 |
+
* @license http://www.gnu.org/licenses/lgpl.html
|
3785 |
+
* @author Thomas Bachem <tb@unitedprototype.com>
|
3786 |
+
* @copyright Copyright (c) 2010 United Prototype GmbH (http://unitedprototype.com)
|
3787 |
+
*/
|
3788 |
+
|
3789 |
+
namespace UnitedPrototype\GoogleAnalytics\Internals\Request{
|
3790 |
+
|
3791 |
+
use UnitedPrototype\GoogleAnalytics\Event;
|
3792 |
+
|
3793 |
+
use UnitedPrototype\GoogleAnalytics\Internals\X10;
|
3794 |
+
|
3795 |
+
class EventRequest extends Request {
|
3796 |
+
|
3797 |
+
/**
|
3798 |
+
* @var \UnitedPrototype\GoogleAnalytics\Event
|
3799 |
+
*/
|
3800 |
+
protected $event;
|
3801 |
+
|
3802 |
+
|
3803 |
+
/**
|
3804 |
+
* @const int
|
3805 |
+
*/
|
3806 |
+
const X10_EVENT_PROJECT_ID = 5;
|
3807 |
+
|
3808 |
+
|
3809 |
+
/**
|
3810 |
+
* @return string
|
3811 |
+
*/
|
3812 |
+
protected function getType() {
|
3813 |
+
return Request::TYPE_EVENT;
|
3814 |
+
}
|
3815 |
+
|
3816 |
+
/**
|
3817 |
+
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/v4/Tracker.as#1503
|
3818 |
+
*
|
3819 |
+
* @return \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder
|
3820 |
+
*/
|
3821 |
+
protected function buildParameters() {
|
3822 |
+
$p = parent::buildParameters();
|
3823 |
+
|
3824 |
+
$x10 = new X10();
|
3825 |
+
|
3826 |
+
$x10->clearKey(self::X10_EVENT_PROJECT_ID);
|
3827 |
+
$x10->clearValue(self::X10_EVENT_PROJECT_ID);
|
3828 |
+
|
3829 |
+
// Object / Category
|
3830 |
+
$x10->setKey(self::X10_EVENT_PROJECT_ID, X10::OBJECT_KEY_NUM, $this->event->getCategory());
|
3831 |
+
|
3832 |
+
// Event Type / Action
|
3833 |
+
$x10->setKey(self::X10_EVENT_PROJECT_ID, X10::TYPE_KEY_NUM, $this->event->getAction());
|
3834 |
+
|
3835 |
+
if($this->event->getLabel() !== null) {
|
3836 |
+
// Event Description / Label
|
3837 |
+
$x10->setKey(self::X10_EVENT_PROJECT_ID, X10::LABEL_KEY_NUM, $this->event->getLabel());
|
3838 |
+
}
|
3839 |
+
|
3840 |
+
if($this->event->getValue() !== null) {
|
3841 |
+
$x10->setValue(self::X10_EVENT_PROJECT_ID, X10::VALUE_VALUE_NUM, $this->event->getValue());
|
3842 |
+
}
|
3843 |
+
|
3844 |
+
$p->utme .= $x10->renderUrlString();
|
3845 |
+
|
3846 |
+
if($this->event->getNoninteraction()) {
|
3847 |
+
$p->utmni = 1;
|
3848 |
+
}
|
3849 |
+
|
3850 |
+
return $p;
|
3851 |
+
}
|
3852 |
+
|
3853 |
+
/**
|
3854 |
+
* @return \UnitedPrototype\GoogleAnalytics\Event
|
3855 |
+
*/
|
3856 |
+
public function getEvent() {
|
3857 |
+
return $this->event;
|
3858 |
+
}
|
3859 |
+
|
3860 |
+
/**
|
3861 |
+
* @param \UnitedPrototype\GoogleAnalytics\Event $event
|
3862 |
+
*/
|
3863 |
+
public function setEvent(Event $event) {
|
3864 |
+
$this->event = $event;
|
3865 |
+
}
|
3866 |
+
|
3867 |
+
}
|
3868 |
+
|
3869 |
+
}
|
3870 |
+
|
3871 |
+
|
3872 |
+
|
3873 |
+
|
3874 |
+
/**
|
3875 |
+
* Generic Server-Side Google Analytics PHP Client
|
3876 |
+
*
|
3877 |
+
* This library is free software; you can redistribute it and/or
|
3878 |
+
* modify it under the terms of the GNU Lesser General Public
|
3879 |
+
* License (LGPL) as published by the Free Software Foundation; either
|
3880 |
+
* version 3 of the License, or (at your option) any later version.
|
3881 |
+
*
|
3882 |
+
* This library is distributed in the hope that it will be useful,
|
3883 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
3884 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
3885 |
+
* Lesser General Public License for more details.
|
3886 |
+
*
|
3887 |
+
* You should have received a copy of the GNU Lesser General Public
|
3888 |
+
* License along with this library; if not, write to the Free Software
|
3889 |
+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
3890 |
+
*
|
3891 |
+
* Google Analytics is a registered trademark of Google Inc.
|
3892 |
+
*
|
3893 |
+
* @link http://code.google.com/p/php-ga
|
3894 |
+
*
|
3895 |
+
* @license http://www.gnu.org/licenses/lgpl.html
|
3896 |
+
* @author Thomas Bachem <tb@unitedprototype.com>
|
3897 |
+
* @copyright Copyright (c) 2010 United Prototype GmbH (http://unitedprototype.com)
|
3898 |
+
*/
|
3899 |
+
|
3900 |
+
namespace UnitedPrototype\GoogleAnalytics\Internals\Request{
|
3901 |
+
|
3902 |
+
use UnitedPrototype\GoogleAnalytics\Config;
|
3903 |
+
|
3904 |
+
use UnitedPrototype\GoogleAnalytics\Internals\Util;
|
3905 |
+
|
3906 |
+
/**
|
3907 |
+
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/core/GIFRequest.as
|
3908 |
+
*/
|
3909 |
+
abstract class HttpRequest {
|
3910 |
+
|
3911 |
+
/**
|
3912 |
+
* Indicates the type of request, will be mapped to "utmt" parameter
|
3913 |
+
*
|
3914 |
+
* @see ParameterHolder::$utmt
|
3915 |
+
* @var string
|
3916 |
+
*/
|
3917 |
+
protected $type;
|
3918 |
+
|
3919 |
+
/**
|
3920 |
+
* @var \UnitedPrototype\GoogleAnalytics\Config
|
3921 |
+
*/
|
3922 |
+
protected $config;
|
3923 |
+
|
3924 |
+
/**
|
3925 |
+
* @var string
|
3926 |
+
*/
|
3927 |
+
protected $xForwardedFor;
|
3928 |
+
|
3929 |
+
/**
|
3930 |
+
* @var string
|
3931 |
+
*/
|
3932 |
+
protected $userAgent;
|
3933 |
+
|
3934 |
+
|
3935 |
+
/**
|
3936 |
+
* @param \UnitedPrototype\GoogleAnalytics\Config $config
|
3937 |
+
*/
|
3938 |
+
public function __construct(Config $config = null) {
|
3939 |
+
$this->setConfig($config ? $config : new Config());
|
3940 |
+
}
|
3941 |
+
|
3942 |
+
/**
|
3943 |
+
* @return \UnitedPrototype\GoogleAnalytics\Config
|
3944 |
+
*/
|
3945 |
+
public function getConfig() {
|
3946 |
+
return $this->config;
|
3947 |
+
}
|
3948 |
+
|
3949 |
+
/**
|
3950 |
+
* @param \UnitedPrototype\GoogleAnalytics\Config $config
|
3951 |
+
*/
|
3952 |
+
public function setConfig(Config $config) {
|
3953 |
+
$this->config = $config;
|
3954 |
+
}
|
3955 |
+
|
3956 |
+
/**
|
3957 |
+
* @param string $value
|
3958 |
+
*/
|
3959 |
+
protected function setXForwardedFor($value) {
|
3960 |
+
$this->xForwardedFor = $value;
|
3961 |
+
}
|
3962 |
+
|
3963 |
+
/**
|
3964 |
+
* @param string $value
|
3965 |
+
*/
|
3966 |
+
protected function setUserAgent($value) {
|
3967 |
+
$this->userAgent = $value;
|
3968 |
+
}
|
3969 |
+
|
3970 |
+
/**
|
3971 |
+
* @return string
|
3972 |
+
*/
|
3973 |
+
protected function buildHttpRequest() {
|
3974 |
+
$parameters = $this->buildParameters();
|
3975 |
+
|
3976 |
+
// This constant is supported as the 4th argument of http_build_query()
|
3977 |
+
// from PHP 5.3.6 on and will tell it to use rawurlencode() instead of urlencode()
|
3978 |
+
// internally, see http://code.google.com/p/php-ga/issues/detail?id=3
|
3979 |
+
if(defined('PHP_QUERY_RFC3986')) {
|
3980 |
+
// http_build_query() does automatically skip all array entries
|
3981 |
+
// with null values, exactly what we want here
|
3982 |
+
$queryString = http_build_query($parameters->toArray(), '', '&', PHP_QUERY_RFC3986);
|
3983 |
+
} else {
|
3984 |
+
// Manually replace "+"s with "%20" for backwards-compatibility
|
3985 |
+
$queryString = str_replace('+', '%20', http_build_query($parameters->toArray(), '', '&'));
|
3986 |
+
}
|
3987 |
+
// Mimic Javascript's encodeURIComponent() encoding for the query
|
3988 |
+
// string just to be sure we are 100% consistent with GA's Javascript client
|
3989 |
+
$queryString = Util::convertToUriComponentEncoding($queryString);
|
3990 |
+
|
3991 |
+
// Recent versions of ga.js use HTTP POST requests if the query string is too long
|
3992 |
+
$usePost = strlen($queryString) > 2036;
|
3993 |
+
|
3994 |
+
if(!$usePost) {
|
3995 |
+
$r = 'GET ' . $this->config->getEndpointPath() . '?' . $queryString . ' HTTP/1.0' . "\r\n";
|
3996 |
+
} else {
|
3997 |
+
// FIXME: The "/p" shouldn't be hardcoded here, instead we need a GET and a POST endpoint...
|
3998 |
+
$r = 'POST /p' . $this->config->getEndpointPath() . ' HTTP/1.0' . "\r\n";
|
3999 |
+
}
|
4000 |
+
$r .= 'Host: ' . $this->config->getEndpointHost() . "\r\n";
|
4001 |
+
|
4002 |
+
if($this->userAgent) {
|
4003 |
+
$r .= 'User-Agent: ' . str_replace(array("\n", "\r"), '', $this->userAgent) . "\r\n";
|
4004 |
+
}
|
4005 |
+
|
4006 |
+
if($this->xForwardedFor) {
|
4007 |
+
// Sadly "X-Fowarded-For" is not supported by GA so far,
|
4008 |
+
// see e.g. http://www.google.com/support/forum/p/Google+Analytics/thread?tid=017691c9e71d4b24,
|
4009 |
+
// but we include it nonetheless for the pure sake of correctness (and hope)
|
4010 |
+
$r .= 'X-Forwarded-For: ' . str_replace(array("\n", "\r"), '', $this->xForwardedFor) . "\r\n";
|
4011 |
+
}
|
4012 |
+
|
4013 |
+
if($usePost) {
|
4014 |
+
// Don't ask me why "text/plain", but ga.js says so :)
|
4015 |
+
$r .= 'Content-Type: text/plain' . "\r\n";
|
4016 |
+
$r .= 'Content-Length: ' . strlen($queryString) . "\r\n";
|
4017 |
+
}
|
4018 |
+
|
4019 |
+
$r .= 'Connection: close' . "\r\n";
|
4020 |
+
$r .= "\r\n\r\n";
|
4021 |
+
|
4022 |
+
if($usePost) {
|
4023 |
+
$r .= $queryString;
|
4024 |
+
}
|
4025 |
+
|
4026 |
+
return $r;
|
4027 |
+
}
|
4028 |
+
|
4029 |
+
/**
|
4030 |
+
* @return \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder
|
4031 |
+
*/
|
4032 |
+
protected abstract function buildParameters();
|
4033 |
+
|
4034 |
+
/**
|
4035 |
+
* This method should only be called directly or indirectly by fire(), but must
|
4036 |
+
* remain public as it can be called by a closure function.
|
4037 |
+
*
|
4038 |
+
* Sends either a normal HTTP request with response or an asynchronous request
|
4039 |
+
* to Google Analytics without waiting for the response. Will always return
|
4040 |
+
* null in the latter case, or false if any connection problems arise.
|
4041 |
+
*
|
4042 |
+
* @see HttpRequest::fire()
|
4043 |
+
* @param string $request
|
4044 |
+
* @return null|string|bool
|
4045 |
+
*/
|
4046 |
+
public function _send() {
|
4047 |
+
$request = $this->buildHttpRequest();
|
4048 |
+
$response = null;
|
4049 |
+
|
4050 |
+
// Do not actually send the request if endpoint host is set to null
|
4051 |
+
if($this->config->getEndpointHost() !== null) {
|
4052 |
+
$timeout = $this->config->getRequestTimeout();
|
4053 |
+
|
4054 |
+
$socket = fsockopen($this->config->getEndpointHost(), 80, $errno, $errstr, $timeout);
|
4055 |
+
if(!$socket) return false;
|
4056 |
+
|
4057 |
+
if($this->config->getFireAndForget()) {
|
4058 |
+
stream_set_blocking($socket, false);
|
4059 |
+
}
|
4060 |
+
|
4061 |
+
$timeoutS = intval($timeout);
|
4062 |
+
$timeoutUs = ($timeout - $timeoutS) * 100000;
|
4063 |
+
stream_set_timeout($socket, $timeoutS, $timeoutUs);
|
4064 |
+
|
4065 |
+
// Ensure that the full request is sent (see http://code.google.com/p/php-ga/issues/detail?id=11)
|
4066 |
+
$sentData = 0;
|
4067 |
+
$toBeSentData = strlen($request);
|
4068 |
+
while($sentData < $toBeSentData) {
|
4069 |
+
$sentData += fwrite($socket, $request);
|
4070 |
+
}
|
4071 |
+
|
4072 |
+
if(!$this->config->getFireAndForget()) {
|
4073 |
+
while(!feof($socket)) {
|
4074 |
+
$response .= fgets($socket, 512);
|
4075 |
+
}
|
4076 |
+
}
|
4077 |
+
|
4078 |
+
fclose($socket);
|
4079 |
+
}
|
4080 |
+
|
4081 |
+
if($loggingCallback = $this->config->getLoggingCallback()) {
|
4082 |
+
$loggingCallback($request, $response);
|
4083 |
+
}
|
4084 |
+
|
4085 |
+
return $response;
|
4086 |
+
}
|
4087 |
+
|
4088 |
+
/**
|
4089 |
+
* Simply delegates to send() if config option "sendOnShutdown" is disabled
|
4090 |
+
* or enqueues the request by registering a PHP shutdown function.
|
4091 |
+
*/
|
4092 |
+
public function fire() {
|
4093 |
+
if($this->config->getSendOnShutdown()) {
|
4094 |
+
// This dumb variable assignment is needed as PHP prohibits using
|
4095 |
+
// $this in closure use statements
|
4096 |
+
$instance = $this;
|
4097 |
+
// We use a closure here to retain the current values/states of
|
4098 |
+
// this instance and $request (as the use statement will copy them
|
4099 |
+
// into its own scope)
|
4100 |
+
register_shutdown_function(function() use($instance) {
|
4101 |
+
$instance->_send();
|
4102 |
+
});
|
4103 |
+
} else {
|
4104 |
+
$this->_send();
|
4105 |
+
}
|
4106 |
+
}
|
4107 |
+
|
4108 |
+
}
|
4109 |
+
|
4110 |
+
}
|
4111 |
+
|
4112 |
+
|
4113 |
+
|
4114 |
+
|
4115 |
+
/**
|
4116 |
+
* Generic Server-Side Google Analytics PHP Client
|
4117 |
+
*
|
4118 |
+
* This library is free software; you can redistribute it and/or
|
4119 |
+
* modify it under the terms of the GNU Lesser General Public
|
4120 |
+
* License (LGPL) as published by the Free Software Foundation; either
|
4121 |
+
* version 3 of the License, or (at your option) any later version.
|
4122 |
+
*
|
4123 |
+
* This library is distributed in the hope that it will be useful,
|
4124 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
4125 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
4126 |
+
* Lesser General Public License for more details.
|
4127 |
+
*
|
4128 |
+
* You should have received a copy of the GNU Lesser General Public
|
4129 |
+
* License along with this library; if not, write to the Free Software
|
4130 |
+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
4131 |
+
*
|
4132 |
+
* Google Analytics is a registered trademark of Google Inc.
|
4133 |
+
*
|
4134 |
+
* @link http://code.google.com/p/php-ga
|
4135 |
+
*
|
4136 |
+
* @license http://www.gnu.org/licenses/lgpl.html
|
4137 |
+
* @author Thomas Bachem <tb@unitedprototype.com>
|
4138 |
+
* @copyright Copyright (c) 2010 United Prototype GmbH (http://unitedprototype.com)
|
4139 |
+
*/
|
4140 |
+
|
4141 |
+
namespace UnitedPrototype\GoogleAnalytics\Internals\Request{
|
4142 |
+
|
4143 |
+
use UnitedPrototype\GoogleAnalytics\Item;
|
4144 |
+
|
4145 |
+
use UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder;
|
4146 |
+
|
4147 |
+
class ItemRequest extends Request {
|
4148 |
+
|
4149 |
+
/**
|
4150 |
+
* @var \UnitedPrototype\GoogleAnalytics\Item
|
4151 |
+
*/
|
4152 |
+
protected $item;
|
4153 |
+
|
4154 |
+
|
4155 |
+
/**
|
4156 |
+
* @return string
|
4157 |
+
*/
|
4158 |
+
protected function getType() {
|
4159 |
+
return Request::TYPE_ITEM;
|
4160 |
+
}
|
4161 |
+
|
4162 |
+
/**
|
4163 |
+
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/ecommerce/Item.as#61
|
4164 |
+
*
|
4165 |
+
* @return \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder
|
4166 |
+
*/
|
4167 |
+
protected function buildParameters() {
|
4168 |
+
$p = parent::buildParameters();
|
4169 |
+
|
4170 |
+
$p->utmtid = $this->item->getOrderId();
|
4171 |
+
$p->utmipc = $this->item->getSku();
|
4172 |
+
$p->utmipn = $this->item->getName();
|
4173 |
+
$p->utmiva = $this->item->getVariation();
|
4174 |
+
$p->utmipr = $this->item->getPrice();
|
4175 |
+
$p->utmiqt = $this->item->getQuantity();
|
4176 |
+
|
4177 |
+
return $p;
|
4178 |
+
}
|
4179 |
+
|
4180 |
+
/**
|
4181 |
+
* The GA Javascript client doesn't send any visitor information for
|
4182 |
+
* e-commerce requests, so we don't either.
|
4183 |
+
*
|
4184 |
+
* @param \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder $p
|
4185 |
+
* @return \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder
|
4186 |
+
*/
|
4187 |
+
protected function buildVisitorParameters(ParameterHolder $p) {
|
4188 |
+
return $p;
|
4189 |
+
}
|
4190 |
+
|
4191 |
+
/**
|
4192 |
+
* The GA Javascript client doesn't send any custom variables for
|
4193 |
+
* e-commerce requests, so we don't either.
|
4194 |
+
*
|
4195 |
+
* @param \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder $p
|
4196 |
+
* @return \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder
|
4197 |
+
*/
|
4198 |
+
protected function buildCustomVariablesParameter(ParameterHolder $p) {
|
4199 |
+
return $p;
|
4200 |
+
}
|
4201 |
+
|
4202 |
+
/**
|
4203 |
+
* @return \UnitedPrototype\GoogleAnalytics\Item
|
4204 |
+
*/
|
4205 |
+
public function getItem() {
|
4206 |
+
return $this->item;
|
4207 |
+
}
|
4208 |
+
|
4209 |
+
/**
|
4210 |
+
* @param \UnitedPrototype\GoogleAnalytics\Item $item
|
4211 |
+
*/
|
4212 |
+
public function setItem(Item $item) {
|
4213 |
+
$this->item = $item;
|
4214 |
+
}
|
4215 |
+
|
4216 |
+
}
|
4217 |
+
|
4218 |
+
}
|
4219 |
+
|
4220 |
+
|
4221 |
+
|
4222 |
+
/**
|
4223 |
+
* Generic Server-Side Google Analytics PHP Client
|
4224 |
+
*
|
4225 |
+
* This library is free software; you can redistribute it and/or
|
4226 |
+
* modify it under the terms of the GNU Lesser General Public
|
4227 |
+
* License (LGPL) as published by the Free Software Foundation; either
|
4228 |
+
* version 3 of the License, or (at your option) any later version.
|
4229 |
+
*
|
4230 |
+
* This library is distributed in the hope that it will be useful,
|
4231 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
4232 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
4233 |
+
* Lesser General Public License for more details.
|
4234 |
+
*
|
4235 |
+
* You should have received a copy of the GNU Lesser General Public
|
4236 |
+
* License along with this library; if not, write to the Free Software
|
4237 |
+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
4238 |
+
*
|
4239 |
+
* Google Analytics is a registered trademark of Google Inc.
|
4240 |
+
*
|
4241 |
+
* @link http://code.google.com/p/php-ga
|
4242 |
+
*
|
4243 |
+
* @license http://www.gnu.org/licenses/lgpl.html
|
4244 |
+
* @author Thomas Bachem <tb@unitedprototype.com>
|
4245 |
+
* @copyright Copyright (c) 2010 United Prototype GmbH (http://unitedprototype.com)
|
4246 |
+
*/
|
4247 |
+
|
4248 |
+
namespace UnitedPrototype\GoogleAnalytics\Internals\Request{
|
4249 |
+
|
4250 |
+
use UnitedPrototype\GoogleAnalytics\Page;
|
4251 |
+
|
4252 |
+
use UnitedPrototype\GoogleAnalytics\Internals\X10;
|
4253 |
+
|
4254 |
+
class PageviewRequest extends Request {
|
4255 |
+
|
4256 |
+
/**
|
4257 |
+
* @var \UnitedPrototype\GoogleAnalytics\Page
|
4258 |
+
*/
|
4259 |
+
protected $page;
|
4260 |
+
|
4261 |
+
|
4262 |
+
/**
|
4263 |
+
* @const int
|
4264 |
+
*/
|
4265 |
+
const X10_SITESPEED_PROJECT_ID = 14;
|
4266 |
+
|
4267 |
+
|
4268 |
+
/**
|
4269 |
+
* @return string
|
4270 |
+
*/
|
4271 |
+
protected function getType() {
|
4272 |
+
return Request::TYPE_PAGE;
|
4273 |
+
}
|
4274 |
+
|
4275 |
+
/**
|
4276 |
+
* @return \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder
|
4277 |
+
*/
|
4278 |
+
protected function buildParameters() {
|
4279 |
+
$p = parent::buildParameters();
|
4280 |
+
|
4281 |
+
$p->utmp = $this->page->getPath();
|
4282 |
+
$p->utmdt = $this->page->getTitle();
|
4283 |
+
if($this->page->getCharset() !== null) {
|
4284 |
+
$p->utmcs = $this->page->getCharset();
|
4285 |
+
}
|
4286 |
+
if($this->page->getReferrer() !== null) {
|
4287 |
+
$p->utmr = $this->page->getReferrer();
|
4288 |
+
}
|
4289 |
+
|
4290 |
+
if($this->page->getLoadTime() !== null) {
|
4291 |
+
// Sample sitespeed measurements
|
4292 |
+
if($p->utmn % 100 < $this->config->getSitespeedSampleRate()) {
|
4293 |
+
$x10 = new X10();
|
4294 |
+
|
4295 |
+
$x10->clearKey(self::X10_SITESPEED_PROJECT_ID);
|
4296 |
+
$x10->clearValue(self::X10_SITESPEED_PROJECT_ID);
|
4297 |
+
|
4298 |
+
// Taken from ga.js code
|
4299 |
+
$key = max(min(floor($this->page->getLoadTime() / 100), 5000), 0) * 100;
|
4300 |
+
$x10->setKey(self::X10_SITESPEED_PROJECT_ID, X10::OBJECT_KEY_NUM, $key);
|
4301 |
+
|
4302 |
+
$x10->setValue(self::X10_SITESPEED_PROJECT_ID, X10::VALUE_VALUE_NUM, $this->page->getLoadTime());
|
4303 |
+
|
4304 |
+
$p->utme .= $x10->renderUrlString();
|
4305 |
+
}
|
4306 |
+
}
|
4307 |
+
|
4308 |
+
return $p;
|
4309 |
+
}
|
4310 |
+
|
4311 |
+
/**
|
4312 |
+
* @return \UnitedPrototype\GoogleAnalytics\Page
|
4313 |
+
*/
|
4314 |
+
public function getPage() {
|
4315 |
+
return $this->page;
|
4316 |
+
}
|
4317 |
+
|
4318 |
+
/**
|
4319 |
+
* @param \UnitedPrototype\GoogleAnalytics\Page $page
|
4320 |
+
*/
|
4321 |
+
public function setPage(Page $page) {
|
4322 |
+
$this->page = $page;
|
4323 |
+
}
|
4324 |
+
|
4325 |
+
}
|
4326 |
+
|
4327 |
+
}
|
4328 |
+
|
4329 |
+
|
4330 |
+
|
4331 |
+
|
4332 |
+
/**
|
4333 |
+
* Generic Server-Side Google Analytics PHP Client
|
4334 |
+
*
|
4335 |
+
* This library is free software; you can redistribute it and/or
|
4336 |
+
* modify it under the terms of the GNU Lesser General Public
|
4337 |
+
* License (LGPL) as published by the Free Software Foundation; either
|
4338 |
+
* version 3 of the License, or (at your option) any later version.
|
4339 |
+
*
|
4340 |
+
* This library is distributed in the hope that it will be useful,
|
4341 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
4342 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
4343 |
+
* Lesser General Public License for more details.
|
4344 |
+
*
|
4345 |
+
* You should have received a copy of the GNU Lesser General Public
|
4346 |
+
* License along with this library; if not, write to the Free Software
|
4347 |
+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
4348 |
+
*
|
4349 |
+
* Google Analytics is a registered trademark of Google Inc.
|
4350 |
+
*
|
4351 |
+
* @link http://code.google.com/p/php-ga
|
4352 |
+
*
|
4353 |
+
* @license http://www.gnu.org/licenses/lgpl.html
|
4354 |
+
* @author Thomas Bachem <tb@unitedprototype.com>
|
4355 |
+
* @copyright Copyright (c) 2010 United Prototype GmbH (http://unitedprototype.com)
|
4356 |
+
*/
|
4357 |
+
|
4358 |
+
namespace UnitedPrototype\GoogleAnalytics\Internals\Request{
|
4359 |
+
|
4360 |
+
use UnitedPrototype\GoogleAnalytics\Tracker;
|
4361 |
+
use UnitedPrototype\GoogleAnalytics\Visitor;
|
4362 |
+
use UnitedPrototype\GoogleAnalytics\Session;
|
4363 |
+
use UnitedPrototype\GoogleAnalytics\CustomVariable;
|
4364 |
+
|
4365 |
+
use UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder;
|
4366 |
+
use UnitedPrototype\GoogleAnalytics\Internals\Util;
|
4367 |
+
use UnitedPrototype\GoogleAnalytics\Internals\X10;
|
4368 |
+
|
4369 |
+
abstract class Request extends HttpRequest {
|
4370 |
+
|
4371 |
+
/**
|
4372 |
+
* @var \UnitedPrototype\GoogleAnalytics\Tracker
|
4373 |
+
*/
|
4374 |
+
protected $tracker;
|
4375 |
+
|
4376 |
+
/**
|
4377 |
+
* @var \UnitedPrototype\GoogleAnalytics\Visitor
|
4378 |
+
*/
|
4379 |
+
protected $visitor;
|
4380 |
+
|
4381 |
+
/**
|
4382 |
+
* @var \UnitedPrototype\GoogleAnalytics\Session
|
4383 |
+
*/
|
4384 |
+
protected $session;
|
4385 |
+
|
4386 |
+
|
4387 |
+
/**
|
4388 |
+
* @const string
|
4389 |
+
*/
|
4390 |
+
const TYPE_PAGE = null;
|
4391 |
+
/**
|
4392 |
+
* @const string
|
4393 |
+
*/
|
4394 |
+
const TYPE_EVENT = 'event';
|
4395 |
+
/**
|
4396 |
+
* @const string
|
4397 |
+
*/
|
4398 |
+
const TYPE_TRANSACTION = 'tran';
|
4399 |
+
/**
|
4400 |
+
* @const string
|
4401 |
+
*/
|
4402 |
+
const TYPE_ITEM = 'item';
|
4403 |
+
/**
|
4404 |
+
* @const string
|
4405 |
+
*/
|
4406 |
+
const TYPE_SOCIAL = 'social';
|
4407 |
+
/**
|
4408 |
+
* This type of request is deprecated in favor of encoding custom variables
|
4409 |
+
* within the "utme" parameter, but we include it here for completeness
|
4410 |
+
*
|
4411 |
+
* @see ParameterHolder::$__utmv
|
4412 |
+
* @link http://code.google.com/apis/analytics/docs/gaJS/gaJSApiBasicConfiguration.html#_gat.GA_Tracker_._setVar
|
4413 |
+
* @deprecated
|
4414 |
+
* @const string
|
4415 |
+
*/
|
4416 |
+
const TYPE_CUSTOMVARIABLE = 'var';
|
4417 |
+
|
4418 |
+
/**
|
4419 |
+
* @const int
|
4420 |
+
*/
|
4421 |
+
const X10_CUSTOMVAR_NAME_PROJECT_ID = 8;
|
4422 |
+
/**
|
4423 |
+
* @const int
|
4424 |
+
*/
|
4425 |
+
const X10_CUSTOMVAR_VALUE_PROJECT_ID = 9;
|
4426 |
+
/**
|
4427 |
+
* @const int
|
4428 |
+
*/
|
4429 |
+
const X10_CUSTOMVAR_SCOPE_PROJECT_ID = 11;
|
4430 |
+
|
4431 |
+
/**
|
4432 |
+
* @const string
|
4433 |
+
*/
|
4434 |
+
const CAMPAIGN_DELIMITER = '|';
|
4435 |
+
|
4436 |
+
|
4437 |
+
/**
|
4438 |
+
* Indicates the type of request, will be mapped to "utmt" parameter
|
4439 |
+
*
|
4440 |
+
* @see ParameterHolder::$utmt
|
4441 |
+
* @return string See Request::TYPE_* constants
|
4442 |
+
*/
|
4443 |
+
protected abstract function getType();
|
4444 |
+
|
4445 |
+
/**
|
4446 |
+
* @return string
|
4447 |
+
*/
|
4448 |
+
protected function buildHttpRequest() {
|
4449 |
+
$this->setXForwardedFor($this->visitor->getIpAddress());
|
4450 |
+
$this->setUserAgent($this->visitor->getUserAgent());
|
4451 |
+
|
4452 |
+
// Increment session track counter for each request
|
4453 |
+
$this->session->increaseTrackCount();
|
4454 |
+
|
4455 |
+
// See http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/v4/Configuration.as?r=237#48
|
4456 |
+
// and http://code.google.com/intl/de-DE/apis/analytics/docs/tracking/eventTrackerGuide.html#implementationConsiderations
|
4457 |
+
if($this->session->getTrackCount() > 500) {
|
4458 |
+
Tracker::_raiseError('Google Analytics does not guarantee to process more than 500 requests per session.', __METHOD__);
|
4459 |
+
}
|
4460 |
+
|
4461 |
+
if($this->tracker->getCampaign()) {
|
4462 |
+
$this->tracker->getCampaign()->increaseResponseCount();
|
4463 |
+
}
|
4464 |
+
|
4465 |
+
return parent::buildHttpRequest();
|
4466 |
+
}
|
4467 |
+
|
4468 |
+
/**
|
4469 |
+
* @return \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder
|
4470 |
+
*/
|
4471 |
+
protected function buildParameters() {
|
4472 |
+
$p = new ParameterHolder();
|
4473 |
+
|
4474 |
+
$p->utmac = $this->tracker->getAccountId();
|
4475 |
+
$p->utmhn = $this->tracker->getDomainName();
|
4476 |
+
|
4477 |
+
$p->utmt = $this->getType();
|
4478 |
+
$p->utmn = Util::generate32bitRandom();
|
4479 |
+
|
4480 |
+
// The "utmip" parameter is only relevant if a mobile analytics
|
4481 |
+
// ID (MO-123456-7) was given,
|
4482 |
+
// see http://code.google.com/p/php-ga/issues/detail?id=9
|
4483 |
+
$p->utmip = $this->visitor->getIpAddress();
|
4484 |
+
|
4485 |
+
$p->aip = $this->tracker->getConfig()->getAnonymizeIpAddresses() ? 1 : null;
|
4486 |
+
if($p->aip) {
|
4487 |
+
// Anonymize last IP block
|
4488 |
+
$p->utmip = substr($p->utmip, 0, strrpos($p->utmip, '.')) . '.0';
|
4489 |
+
}
|
4490 |
+
|
4491 |
+
$p->utmhid = $this->session->getSessionId();
|
4492 |
+
$p->utms = $this->session->getTrackCount();
|
4493 |
+
|
4494 |
+
$p = $this->buildVisitorParameters($p);
|
4495 |
+
$p = $this->buildCustomVariablesParameter($p);
|
4496 |
+
$p = $this->buildCampaignParameters($p);
|
4497 |
+
$p = $this->buildCookieParameters($p);
|
4498 |
+
|
4499 |
+
return $p;
|
4500 |
+
}
|
4501 |
+
|
4502 |
+
/**
|
4503 |
+
* @param \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder $p
|
4504 |
+
* @return \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder
|
4505 |
+
*/
|
4506 |
+
protected function buildVisitorParameters(ParameterHolder $p) {
|
4507 |
+
// Ensure correct locale format, see https://developer.mozilla.org/en/navigator.language
|
4508 |
+
$p->utmul = strtolower(str_replace('_', '-', $this->visitor->getLocale()));
|
4509 |
+
|
4510 |
+
if($this->visitor->getFlashVersion() !== null) {
|
4511 |
+
$p->utmfl = $this->visitor->getFlashVersion();
|
4512 |
+
}
|
4513 |
+
if($this->visitor->getJavaEnabled() !== null) {
|
4514 |
+
$p->utmje = $this->visitor->getJavaEnabled();
|
4515 |
+
}
|
4516 |
+
if($this->visitor->getScreenColorDepth() !== null) {
|
4517 |
+
$p->utmsc = $this->visitor->getScreenColorDepth() . '-bit';
|
4518 |
+
}
|
4519 |
+
$p->utmsr = $this->visitor->getScreenResolution();
|
4520 |
+
|
4521 |
+
return $p;
|
4522 |
+
}
|
4523 |
+
|
4524 |
+
/**
|
4525 |
+
* @link http://xahlee.org/js/google_analytics_tracker_2010-07-01_expanded.js line 575
|
4526 |
+
* @param \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder $p
|
4527 |
+
* @return \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder
|
4528 |
+
*/
|
4529 |
+
protected function buildCustomVariablesParameter(ParameterHolder $p) {
|
4530 |
+
$customVars = $this->tracker->getCustomVariables();
|
4531 |
+
if($customVars) {
|
4532 |
+
if(count($customVars) > 5) {
|
4533 |
+
// See http://code.google.com/intl/de-DE/apis/analytics/docs/tracking/gaTrackingCustomVariables.html#usage
|
4534 |
+
Tracker::_raiseError('The sum of all custom variables cannot exceed 5 in any given request.', __METHOD__);
|
4535 |
+
}
|
4536 |
+
|
4537 |
+
$x10 = new X10();
|
4538 |
+
|
4539 |
+
$x10->clearKey(self::X10_CUSTOMVAR_NAME_PROJECT_ID);
|
4540 |
+
$x10->clearKey(self::X10_CUSTOMVAR_VALUE_PROJECT_ID);
|
4541 |
+
$x10->clearKey(self::X10_CUSTOMVAR_SCOPE_PROJECT_ID);
|
4542 |
+
|
4543 |
+
foreach($customVars as $customVar) {
|
4544 |
+
// Name and value get encoded here,
|
4545 |
+
// see http://xahlee.org/js/google_analytics_tracker_2010-07-01_expanded.js line 563
|
4546 |
+
$name = Util::encodeUriComponent($customVar->getName());
|
4547 |
+
$value = Util::encodeUriComponent($customVar->getValue());
|
4548 |
+
|
4549 |
+
$x10->setKey(self::X10_CUSTOMVAR_NAME_PROJECT_ID, $customVar->getIndex(), $name);
|
4550 |
+
$x10->setKey(self::X10_CUSTOMVAR_VALUE_PROJECT_ID, $customVar->getIndex(), $value);
|
4551 |
+
if($customVar->getScope() !== null && $customVar->getScope() != CustomVariable::SCOPE_PAGE) {
|
4552 |
+
$x10->setKey(self::X10_CUSTOMVAR_SCOPE_PROJECT_ID, $customVar->getIndex(), $customVar->getScope());
|
4553 |
+
}
|
4554 |
+
}
|
4555 |
+
|
4556 |
+
$p->utme .= $x10->renderUrlString();
|
4557 |
+
}
|
4558 |
+
|
4559 |
+
return $p;
|
4560 |
+
}
|
4561 |
+
|
4562 |
+
/**
|
4563 |
+
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/core/GIFRequest.as#123
|
4564 |
+
* @param \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder $p
|
4565 |
+
* @return \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder
|
4566 |
+
*/
|
4567 |
+
protected function buildCookieParameters(ParameterHolder $p) {
|
4568 |
+
$domainHash = $this->generateDomainHash();
|
4569 |
+
|
4570 |
+
$p->__utma = $domainHash . '.';
|
4571 |
+
$p->__utma .= $this->visitor->getUniqueId() . '.';
|
4572 |
+
$p->__utma .= $this->visitor->getFirstVisitTime()->format('U') . '.';
|
4573 |
+
$p->__utma .= $this->visitor->getPreviousVisitTime()->format('U') . '.';
|
4574 |
+
$p->__utma .= $this->visitor->getCurrentVisitTime()->format('U') . '.';
|
4575 |
+
$p->__utma .= $this->visitor->getVisitCount();
|
4576 |
+
|
4577 |
+
$p->__utmb = $domainHash . '.';
|
4578 |
+
$p->__utmb .= $this->session->getTrackCount() . '.';
|
4579 |
+
// FIXME: What does "token" mean? I only encountered a value of 10 in my tests.
|
4580 |
+
$p->__utmb .= 10 . '.';
|
4581 |
+
$p->__utmb .= $this->session->getStartTime()->format('U');
|
4582 |
+
|
4583 |
+
$p->__utmc = $domainHash;
|
4584 |
+
|
4585 |
+
$cookies = array();
|
4586 |
+
$cookies[] = '__utma=' . $p->__utma . ';';
|
4587 |
+
if($p->__utmz) {
|
4588 |
+
$cookies[] = '__utmz=' . $p->__utmz . ';';
|
4589 |
+
}
|
4590 |
+
if($p->__utmv) {
|
4591 |
+
$cookies[] = '__utmv=' . $p->__utmv . ';';
|
4592 |
+
}
|
4593 |
+
|
4594 |
+
$p->utmcc = implode('+', $cookies);
|
4595 |
+
|
4596 |
+
return $p;
|
4597 |
+
}
|
4598 |
+
|
4599 |
+
/**
|
4600 |
+
* @param \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder $p
|
4601 |
+
* @return \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder
|
4602 |
+
*/
|
4603 |
+
protected function buildCampaignParameters(ParameterHolder $p) {
|
4604 |
+
$campaign = $this->tracker->getCampaign();
|
4605 |
+
if($campaign) {
|
4606 |
+
$p->__utmz = $this->generateDomainHash() . '.';
|
4607 |
+
$p->__utmz .= $campaign->getCreationTime()->format('U') . '.';
|
4608 |
+
$p->__utmz .= $this->visitor->getVisitCount() . '.';
|
4609 |
+
$p->__utmz .= $campaign->getResponseCount() . '.';
|
4610 |
+
|
4611 |
+
// See http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/campaign/CampaignTracker.as#236
|
4612 |
+
$data = array(
|
4613 |
+
'utmcid' => $campaign->getId(),
|
4614 |
+
'utmcsr' => $campaign->getSource(),
|
4615 |
+
'utmgclid' => $campaign->getGClickId(),
|
4616 |
+
'utmdclid' => $campaign->getDClickId(),
|
4617 |
+
'utmccn' => $campaign->getName(),
|
4618 |
+
'utmcmd' => $campaign->getMedium(),
|
4619 |
+
'utmctr' => $campaign->getTerm(),
|
4620 |
+
'utmcct' => $campaign->getContent(),
|
4621 |
+
);
|
4622 |
+
foreach($data as $key => $value) {
|
4623 |
+
if($value !== null && $value !== '') {
|
4624 |
+
// Only spaces and pluses get escaped in gaforflash and ga.js, so we do the same
|
4625 |
+
$p->__utmz .= $key . '=' . str_replace(array('+', ' '), '%20', $value) . static::CAMPAIGN_DELIMITER;
|
4626 |
+
}
|
4627 |
+
}
|
4628 |
+
$p->__utmz = rtrim($p->__utmz, static::CAMPAIGN_DELIMITER);
|
4629 |
+
}
|
4630 |
+
|
4631 |
+
return $p;
|
4632 |
+
}
|
4633 |
+
|
4634 |
+
/**
|
4635 |
+
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/v4/Tracker.as#585
|
4636 |
+
* @return string
|
4637 |
+
*/
|
4638 |
+
protected function generateDomainHash() {
|
4639 |
+
$hash = 1;
|
4640 |
+
|
4641 |
+
if($this->tracker->getAllowHash()) {
|
4642 |
+
$hash = Util::generateHash($this->tracker->getDomainName());
|
4643 |
+
}
|
4644 |
+
|
4645 |
+
return $hash;
|
4646 |
+
}
|
4647 |
+
|
4648 |
+
/**
|
4649 |
+
* @return \UnitedPrototype\GoogleAnalytics\Tracker
|
4650 |
+
*/
|
4651 |
+
public function getTracker() {
|
4652 |
+
return $this->tracker;
|
4653 |
+
}
|
4654 |
+
|
4655 |
+
/**
|
4656 |
+
* @param \UnitedPrototype\GoogleAnalytics\Tracker $tracker
|
4657 |
+
*/
|
4658 |
+
public function setTracker(Tracker $tracker) {
|
4659 |
+
$this->tracker = $tracker;
|
4660 |
+
}
|
4661 |
+
|
4662 |
+
/**
|
4663 |
+
* @return \UnitedPrototype\GoogleAnalytics\Visitor
|
4664 |
+
*/
|
4665 |
+
public function getVisitor() {
|
4666 |
+
return $this->visitor;
|
4667 |
+
}
|
4668 |
+
|
4669 |
+
/**
|
4670 |
+
* @param \UnitedPrototype\GoogleAnalytics\Visitor $visitor
|
4671 |
+
*/
|
4672 |
+
public function setVisitor(Visitor $visitor) {
|
4673 |
+
$this->visitor = $visitor;
|
4674 |
+
}
|
4675 |
+
|
4676 |
+
/**
|
4677 |
+
* @return \UnitedPrototype\GoogleAnalytics\Session
|
4678 |
+
*/
|
4679 |
+
public function getSession() {
|
4680 |
+
return $this->session;
|
4681 |
+
}
|
4682 |
+
|
4683 |
+
/**
|
4684 |
+
* @param \UnitedPrototype\GoogleAnalytics\Session $session
|
4685 |
+
*/
|
4686 |
+
public function setSession(Session $session) {
|
4687 |
+
$this->session = $session;
|
4688 |
+
}
|
4689 |
+
|
4690 |
+
}
|
4691 |
+
|
4692 |
+
}
|
4693 |
+
|
4694 |
+
|
4695 |
+
|
4696 |
+
|
4697 |
+
/**
|
4698 |
+
* Generic Server-Side Google Analytics PHP Client
|
4699 |
+
*
|
4700 |
+
* This library is free software; you can redistribute it and/or
|
4701 |
+
* modify it under the terms of the GNU Lesser General Public
|
4702 |
+
* License (LGPL) as published by the Free Software Foundation; either
|
4703 |
+
* version 3 of the License, or (at your option) any later version.
|
4704 |
+
*
|
4705 |
+
* This library is distributed in the hope that it will be useful,
|
4706 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
4707 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
4708 |
+
* Lesser General Public License for more details.
|
4709 |
+
*
|
4710 |
+
* You should have received a copy of the GNU Lesser General Public
|
4711 |
+
* License along with this library; if not, write to the Free Software
|
4712 |
+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
4713 |
+
*
|
4714 |
+
* Google Analytics is a registered trademark of Google Inc.
|
4715 |
+
*
|
4716 |
+
* @link http://code.google.com/p/php-ga
|
4717 |
+
*
|
4718 |
+
* @license http://www.gnu.org/licenses/lgpl.html
|
4719 |
+
* @author Thomas Bachem <tb@unitedprototype.com>
|
4720 |
+
* @copyright Copyright (c) 2010 United Prototype GmbH (http://unitedprototype.com)
|
4721 |
+
*/
|
4722 |
+
|
4723 |
+
namespace UnitedPrototype\GoogleAnalytics\Internals\Request{
|
4724 |
+
|
4725 |
+
use UnitedPrototype\GoogleAnalytics\SocialInteraction;
|
4726 |
+
|
4727 |
+
class SocialinteractionRequest extends PageviewRequest {
|
4728 |
+
|
4729 |
+
/**
|
4730 |
+
* @var \UnitedPrototype\GoogleAnalytics\SocialInteraction
|
4731 |
+
*/
|
4732 |
+
protected $socialInteraction;
|
4733 |
+
|
4734 |
+
|
4735 |
+
/**
|
4736 |
+
* @return string
|
4737 |
+
*/
|
4738 |
+
protected function getType() {
|
4739 |
+
return Request::TYPE_SOCIAL;
|
4740 |
+
}
|
4741 |
+
|
4742 |
+
/**
|
4743 |
+
* @return \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder
|
4744 |
+
*/
|
4745 |
+
protected function buildParameters() {
|
4746 |
+
$p = parent::buildParameters();
|
4747 |
+
|
4748 |
+
$p->utmsn = $this->socialInteraction->getNetwork();
|
4749 |
+
$p->utmsa = $this->socialInteraction->getAction();
|
4750 |
+
$p->utmsid = $this->socialInteraction->getTarget();
|
4751 |
+
if($p->utmsid === null) {
|
4752 |
+
// Default to page path like ga.js,
|
4753 |
+
// see http://code.google.com/apis/analytics/docs/tracking/gaTrackingSocial.html#settingUp
|
4754 |
+
$p->utmsid = $this->page->getPath();
|
4755 |
+
}
|
4756 |
+
|
4757 |
+
return $p;
|
4758 |
+
}
|
4759 |
+
|
4760 |
+
/**
|
4761 |
+
* @return \UnitedPrototype\GoogleAnalytics\SocialInteraction
|
4762 |
+
*/
|
4763 |
+
public function getSocialInteraction() {
|
4764 |
+
return $this->socialInteraction;
|
4765 |
+
}
|
4766 |
+
|
4767 |
+
/**
|
4768 |
+
* @param \UnitedPrototype\GoogleAnalytics\SocialInteraction $socialInteraction
|
4769 |
+
*/
|
4770 |
+
public function setSocialInteraction(SocialInteraction $socialInteraction) {
|
4771 |
+
$this->socialInteraction = $socialInteraction;
|
4772 |
+
}
|
4773 |
+
|
4774 |
+
}
|
4775 |
+
|
4776 |
+
}
|
4777 |
+
|
4778 |
+
|
4779 |
+
|
4780 |
+
|
4781 |
+
/**
|
4782 |
+
* Generic Server-Side Google Analytics PHP Client
|
4783 |
+
*
|
4784 |
+
* This library is free software; you can redistribute it and/or
|
4785 |
+
* modify it under the terms of the GNU Lesser General Public
|
4786 |
+
* License (LGPL) as published by the Free Software Foundation; either
|
4787 |
+
* version 3 of the License, or (at your option) any later version.
|
4788 |
+
*
|
4789 |
+
* This library is distributed in the hope that it will be useful,
|
4790 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
4791 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
4792 |
+
* Lesser General Public License for more details.
|
4793 |
+
*
|
4794 |
+
* You should have received a copy of the GNU Lesser General Public
|
4795 |
+
* License along with this library; if not, write to the Free Software
|
4796 |
+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
4797 |
+
*
|
4798 |
+
* Google Analytics is a registered trademark of Google Inc.
|
4799 |
+
*
|
4800 |
+
* @link http://code.google.com/p/php-ga
|
4801 |
+
*
|
4802 |
+
* @license http://www.gnu.org/licenses/lgpl.html
|
4803 |
+
* @author Thomas Bachem <tb@unitedprototype.com>
|
4804 |
+
* @copyright Copyright (c) 2010 United Prototype GmbH (http://unitedprototype.com)
|
4805 |
+
*/
|
4806 |
+
|
4807 |
+
namespace UnitedPrototype\GoogleAnalytics\Internals\Request{
|
4808 |
+
|
4809 |
+
use UnitedPrototype\GoogleAnalytics\Transaction;
|
4810 |
+
|
4811 |
+
use UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder;
|
4812 |
+
|
4813 |
+
class TransactionRequest extends Request {
|
4814 |
+
|
4815 |
+
/**
|
4816 |
+
* @var \UnitedPrototype\GoogleAnalytics\Transaction
|
4817 |
+
*/
|
4818 |
+
protected $transaction;
|
4819 |
+
|
4820 |
+
|
4821 |
+
/**
|
4822 |
+
* @return string
|
4823 |
+
*/
|
4824 |
+
protected function getType() {
|
4825 |
+
return Request::TYPE_TRANSACTION;
|
4826 |
+
}
|
4827 |
+
|
4828 |
+
/**
|
4829 |
+
* @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/ecommerce/Transaction.as#76
|
4830 |
+
*
|
4831 |
+
* @return \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder
|
4832 |
+
*/
|
4833 |
+
protected function buildParameters() {
|
4834 |
+
$p = parent::buildParameters();
|
4835 |
+
|
4836 |
+
$p->utmtid = $this->transaction->getOrderId();
|
4837 |
+
$p->utmtst = $this->transaction->getAffiliation();
|
4838 |
+
$p->utmtto = $this->transaction->getTotal();
|
4839 |
+
$p->utmttx = $this->transaction->getTax();
|
4840 |
+
$p->utmtsp = $this->transaction->getShipping();
|
4841 |
+
$p->utmtci = $this->transaction->getCity();
|
4842 |
+
$p->utmtrg = $this->transaction->getRegion();
|
4843 |
+
$p->utmtco = $this->transaction->getCountry();
|
4844 |
+
|
4845 |
+
return $p;
|
4846 |
+
}
|
4847 |
+
|
4848 |
+
/**
|
4849 |
+
* The GA Javascript client doesn't send any visitor information for
|
4850 |
+
* e-commerce requests, so we don't either.
|
4851 |
+
*
|
4852 |
+
* @param \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder $p
|
4853 |
+
* @return \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder
|
4854 |
+
*/
|
4855 |
+
protected function buildVisitorParameters(ParameterHolder $p) {
|
4856 |
+
return $p;
|
4857 |
+
}
|
4858 |
+
|
4859 |
+
/**
|
4860 |
+
* The GA Javascript client doesn't send any custom variables for
|
4861 |
+
* e-commerce requests, so we don't either.
|
4862 |
+
*
|
4863 |
+
* @param \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder $p
|
4864 |
+
* @return \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder
|
4865 |
+
*/
|
4866 |
+
protected function buildCustomVariablesParameter(ParameterHolder $p) {
|
4867 |
+
return $p;
|
4868 |
+
}
|
4869 |
+
|
4870 |
+
/**
|
4871 |
+
* @return \UnitedPrototype\GoogleAnalytics\Transaction
|
4872 |
+
*/
|
4873 |
+
public function getTransaction() {
|
4874 |
+
return $this->transaction;
|
4875 |
+
}
|
4876 |
+
|
4877 |
+
/**
|
4878 |
+
* @param \UnitedPrototype\GoogleAnalytics\Transaction $transaction
|
4879 |
+
*/
|
4880 |
+
public function setTransaction(Transaction $transaction) {
|
4881 |
+
$this->transaction = $transaction;
|
4882 |
+
}
|
4883 |
+
|
4884 |
+
}
|
4885 |
+
|
4886 |
+
}
|
4887 |
+
?>
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>sluice_connect</name>
|
4 |
-
<version>0.1.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.gnu.org/licenses/gpl.html">GPL</license>
|
7 |
<channel>community</channel>
|
@@ -11,9 +11,9 @@
|
|
11 |
<notes>- Track add to cart event (via google analitics)
|
12 |
- Give Magento data access to Sluice HQ (via Web Services)</notes>
|
13 |
<authors><author><name>Konstantin</name><user>flyb1z0n</user><email>flyb1z0n@gmail.com</email></author></authors>
|
14 |
-
<date>2013-05-
|
15 |
-
<time>
|
16 |
-
<contents><target name="magelocal"><dir name="Sluice"><dir name="Connect"><dir name="Helper"><file name="Data.php" hash="72f7af6ab8f4dd94d7e0d56f2355e84a"/></dir><dir name="Model"><file name="Observer.php" hash="
|
17 |
<compatible/>
|
18 |
-
<dependencies><required><php><min>5.
|
19 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>sluice_connect</name>
|
4 |
+
<version>0.1.2</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.gnu.org/licenses/gpl.html">GPL</license>
|
7 |
<channel>community</channel>
|
11 |
<notes>- Track add to cart event (via google analitics)
|
12 |
- Give Magento data access to Sluice HQ (via Web Services)</notes>
|
13 |
<authors><author><name>Konstantin</name><user>flyb1z0n</user><email>flyb1z0n@gmail.com</email></author></authors>
|
14 |
+
<date>2013-05-11</date>
|
15 |
+
<time>16:36:18</time>
|
16 |
+
<contents><target name="magelocal"><dir><dir name="Sluice"><dir name="Connect"><dir name="Helper"><file name="Data.php" hash="72f7af6ab8f4dd94d7e0d56f2355e84a"/></dir><dir name="Model"><file name="Observer.php" hash="330268fd45446d9d8af7cdb60ce12769"/></dir><dir name="etc"><file name="config.xml" hash="a0d266785b3068b867d5110c7df8b397"/><file name="system.xml" hash="7c00c55ed5ec73bc35df97d4781ca4bd"/></dir></dir></dir></dir></target><target name="magelib"><dir><dir name="GA-client"><file name="GA-client.php" hash="9d36d0998d30e475d0417b790a244261"/></dir></dir></target></contents>
|
17 |
<compatible/>
|
18 |
+
<dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
|
19 |
</package>
|