-
Notifications
You must be signed in to change notification settings - Fork 1
/
demo.php
170 lines (135 loc) · 4.27 KB
/
demo.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
ini_set('default_socket_timeout', 2);
error_reporting(E_ALL);
session_start();
session_destroy();
require_once 'src/Client.php';
require_once 'src/Filter.php';
// Configuration
$clientID = '9EisID5H4jTpSwrxHiTrHEstmn2isNH0';
$clientSecret = 'Vw2guiFFahW7KemRCFIYxkJF9mzULgx8Q6HMQrEDhRclQstphklHPgBfo4BL0lix';
$baseURL = Pirsch\Client::DEFAULT_BASE_URL; // https://localhost.com:9999
$sendData = false;
$client = new Pirsch\Client($clientID, $clientSecret, Pirsch\Client::DEFAULT_TIMEOUT, $baseURL);
if ($sendData) {
try {
$client->hit();
print '<p>Hit sent!</p>';
} catch(Exception $e) {
print '<p>An error occurred while sending the hit: </p>'.$e->getMessage();
}
try {
$client->event('PHP', 42, ['hello' => 'world']);
print '<p>Event sent!</p>';
} catch(Exception $e) {
print '<p>An error occurred while sending the event: </p>'.$e->getMessage();
}
}
try {
$domain = $client->domain();
var_dump($domain);
echo '<br /><br />';
$filter = new Pirsch\Filter();
$filter->id = $domain->id;
$filter->from = date('Y-m-d', strtotime('-7 days'));
$filter->to = date('Y-m-d');
var_dump($filter);
echo '<br /><br />';
$sessionDuration = $client->sessionDuration($filter);
var_dump($sessionDuration);
echo '<br /><br />';
$timeOnPage = $client->timeOnPage($filter);
var_dump($timeOnPage);
echo '<br /><br />';
$utmSource = $client->utmSource($filter);
var_dump($utmSource);
echo '<br /><br />';
$utmMedium = $client->utmMedium($filter);
var_dump($utmMedium);
echo '<br /><br />';
$utmCampaign = $client->utmCampaign($filter);
var_dump($utmCampaign);
echo '<br /><br />';
$utmContent = $client->utmContent($filter);
var_dump($utmContent);
echo '<br /><br />';
$utmTerm = $client->utmTerm($filter);
var_dump($utmTerm);
echo '<br /><br />';
$visitors = $client->visitors($filter);
var_dump($visitors);
echo '<br /><br />';
$pages = $client->pages($filter);
var_dump($pages);
echo '<br /><br />';
$entryPages = $client->entryPages($filter);
var_dump($entryPages);
echo '<br /><br />';
$exitPages = $client->exitPages($filter);
var_dump($exitPages);
echo '<br /><br />';
$conversionGoals = $client->conversionGoals($filter);
var_dump($conversionGoals);
echo '<br /><br />';
echo '<h2>Events</h2>';
$filter->event = 'PHP';
$events = $client->events($filter);
var_dump($events);
echo '<br /><br />';
echo '<h2>Event Metadata</h2>';
$filter->event_meta_key = 'hello';
$metadata = $client->eventMetadata($filter);
var_dump($metadata);
echo '<br /><br />';
$filter->event = '';
$filter->event_meta_key = '';
$growth = $client->growth($filter);
var_dump($growth);
echo '<br /><br />';
$activeVisitors = $client->activeVisitors($filter);
var_dump($activeVisitors);
echo '<br /><br />';
$timeOfDay = $client->timeOfDay($filter);
var_dump($timeOfDay);
echo '<br /><br />';
$languages = $client->languages($filter);
var_dump($languages);
echo '<br /><br />';
$referrer = $client->referrer($filter);
var_dump($referrer);
echo '<br /><br />';
$os = $client->os($filter);
var_dump($os);
echo '<br /><br />';
$browser = $client->browser($filter);
var_dump($browser);
echo '<br /><br />';
$country = $client->country($filter);
var_dump($country);
echo '<br /><br />';
$city = $client->city($filter);
var_dump($city);
echo '<br /><br />';
$platform = $client->platform($filter);
var_dump($platform);
echo '<br /><br />';
$screen = $client->screen($filter);
var_dump($screen);
echo '<br /><br />';
$keywords = $client->keywords($filter);
var_dump($keywords);
echo '<br /><br />';
$funnel = $client->listFunnel($filter);
var_dump($funnel);
echo '<br /><br />';
foreach ($funnel as $f) {
$filter->funnel_id = $f->id;
$data = $client->funnel($filter);
var_dump($data);
echo '<br /><br />';
}
} catch(Exception $e) {
print '<p>An error occurred while reading the statistics: </p>'.$e->getMessage();
}