srchub

srchub Commit Details


Date:2014-03-10 22:34:32 (10 years 9 months ago)
Author:Natalie Adams
Branch:master
Commit:22de793422fa15775008b5f7132c619599e87983
Parents: cc6f03a62d719a619f95fb26663fa886e3d943d0
Message:Updating google analytics in Pluf framework

Changes:

File differences

pluf/src/Pluf/Middleware/GoogleAnalytics.php
4343
4444
4545
46
47
46
47
4848
4949
5050
......
5858
5959
6060
61
62
63
61
62
63
64
65
66
67
68
69
70
71
72
6473
65
66
67
68
74
6975
7076
7177
if (!Pluf::f('google_analytics_id', false)) {
return $response;
}
if (!in_array($response->status_code,
array(200, 201, 202, 203, 204, 205, 206, 404, 501))) {
if (!in_array($response->status_code,
array(200, 201, 202, 203, 204, 205, 206, 404, 501))) {
return $response;
}
$ok = false;
if ($ok == false) {
return $response;
}
$js = '<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src=\'" + gaJsHost + "google-analytics.com/ga.js\' type=\'text/javascript\'%3E%3C/script%3E"));
$track = Pluf::f('google_analytics_id', '');
$domain = Pluf::f('google_analytics_domain', '');
$js = <<<EOT
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', '$track', '$domain');
ga('send', 'pageview');
</script>
<script type="text/javascript"> try {
var pageTracker = _gat._getTracker("'.Pluf::f('google_analytics_id').'");
pageTracker._trackPageview(); } catch(err) {}
</script>';
EOT;
$response->content = str_replace('</body>', $js.'</body>', $response->content);
return $response;
}

Archive Download the corresponding diff file

Branches

Number of commits:
Page rendered in 0.06222s using 14 queries.