Conditions | 5 |
Paths | 6 |
Total Lines | 26 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 7 |
CRAP Score | 5.675 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
17 | 12 | public function googleAnalytics($trackingCode = null) |
|
18 | { |
||
19 | 12 | if (!is_string($trackingCode)) { |
|
20 | global $application; |
||
21 | 12 | if ($application instanceof Zend_Application) { |
|
22 | 12 | $trackingCode = $application->getOption('googleAnalyticsTrackingCode'); |
|
23 | } |
||
24 | } |
||
25 | |||
26 | 12 | $trackingCode = trim($trackingCode); |
|
27 | 12 | if (!is_string($trackingCode) || empty($trackingCode)) { |
|
|
|||
28 | 12 | return ''; |
|
29 | } |
||
30 | |||
31 | $result = <<<STRING |
||
32 | <script async src="https://www.googletagmanager.com/gtag/js?id=$trackingCode"></script> |
||
33 | <script> |
||
34 | window.dataLayer = window.dataLayer || []; |
||
35 | function gtag(){dataLayer.push(arguments);} |
||
36 | gtag('js', new Date()); |
||
37 | |||
38 | gtag('config', '$trackingCode'); |
||
39 | </script> |
||
40 | STRING; |
||
41 | |||
42 | return $result; |
||
43 | } |
||
45 |