-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathsetup.example.php
58 lines (44 loc) · 1.71 KB
/
setup.example.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
<?php
/**********************
* Account information
***********************/
define('GOOGLE_APPLICATION_NAME',
'Example Analytics');
define('GOOGLE_CLIENT_EMAIL',
define('GOOGLE_USER_EMAIL',
// Appears under "View Settings" in "Admin" section for your analytics as "View ID"
define('GOOGLE_ANALYTICS_PROFILE_ID',
'1111111');
// Appears at the end of the URL when logged into your Analytics page. Example:
// https://www.google.com/analytics/web/?hl=en#report/visitors-overview/a1111111w2222222p3333333/
define('GOOGLE_ANALYTICS_WEB_ID',
'a1111111w2222222p3333333');
// Make an incoming webhook here:
// https://YOURSLACK.slack.com/services/new/incoming-webhook
define('SLACK_WEBHOOK_URL',
'https://EXAMPLE.slack.com/services/hooks/incoming-webhook?token=EXAMPLE');
define('YOUR_DOMAIN',
'http://example.com');
set_include_path( get_include_path() . PATH_SEPARATOR . dirname(__FILE__) );
require_once 'Google/Client.php';
require_once 'Google/Service/Analytics.php';
session_start();
$client = new Google_Client();
$client->setApplicationName(GOOGLE_APPLICATION_NAME);
// Replace this with the service you are using.
$analytics = new Google_Service_Analytics($client);
$key_file_location = dirname(__FILE__).'/privatekey.p12';
// This file location should point to the private key file.
$key = file_get_contents($key_file_location);
$cred = new Google_Auth_AssertionCredentials(
// Replace this with the email address from the client.
GOOGLE_CLIENT_EMAIL,
// Replace this with the scopes you are requesting.
array('https://www.googleapis.com/auth/analytics.readonly'),
$key
);
$cred->sub = GOOGLE_USER_EMAIL;
$client->setAssertionCredentials($cred);
?>