-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathGoogleAnalytics.php
More file actions
41 lines (37 loc) · 1.28 KB
/
GoogleAnalytics.php
File metadata and controls
41 lines (37 loc) · 1.28 KB
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
<?php
namespace Silverstripe\CSP\Fragments;
use Silverstripe\CSP\Directive;
use Silverstripe\CSP\Policies\Policy;
/**
* This allows you to have a Google analytics related resources
*/
class GoogleAnalytics implements Fragment
{
public static function addTo(Policy $policy): void
{
$policy
->addDirective(Directive::SCRIPT, [
'https://*.google-analytics.com',
])
->addDirective(Directive::SCRIPT_ELEM, [
'https://*.google-analytics.com',
'https://*.googletagmanager.com',
'https://www.googleadservices.com',
])
->addDirective(Directive::CONNECT, [
'https://*.google-analytics.com',
'https://*.analytics.google.com',
'https://*.googletagmanager.com',
'https://www.google.co.nz/ads/ga-audiences',
'https://google.com',
'https://*.google.com',
'https://www.google.com.au',
'https://www.googleadservices.com',
'https://*.googleapis.com',
])
->addDirective(Directive::IMG, [
'https://*.google-analytics.com',
'https://*.googletagmanager.com',
]);
}
}