Skip to content

Commit

Permalink
Make the Google Analytics web property ID configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
cgunther committed Nov 26, 2013
1 parent 2ae81c0 commit be08913
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
5 changes: 5 additions & 0 deletions config.php
Expand Up @@ -6,3 +6,8 @@
//
// Also update the RewriteBase at the bottom of the htaccess file if the site lives in a subdirectory
$config['base_url'] = 'http://php-boilerplate.dev/';

// Google Analytics Web Property ID
//
// Ex. UA-XXXXX-X
$config['google_analytics_web_property_id'] = '';
14 changes: 8 additions & 6 deletions layouts/application.php
Expand Up @@ -26,12 +26,14 @@
<?php javascripts('script'); yield('javascripts'); ?>
<!--<![endif]-->

<script>
var _gaq=[['_setAccount','UA-XXXXX-X'],['_trackPageview']];
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
s.parentNode.insertBefore(g,s)}(document,'script'));
</script>
<?php if ($config['google_analytics_web_property_id'] != ''): ?>
<script>
var _gaq=[['_setAccount','<?php echo $config['google_analytics_web_property_id']; ?>'],['_trackPageview']];
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
s.parentNode.insertBefore(g,s)}(document,'script'));
</script>
<?php endif; ?>

<!--[if lt IE 7 ]>
<div style="clear: both; height: 59px; padding: 0; position: absolute; left: 50%; top: 0; margin-left: -410px;">
Expand Down

0 comments on commit be08913

Please sign in to comment.