Skip to content

Commit

Permalink
Merge pull request #19 from bit-docs/48-google-analytics
Browse files Browse the repository at this point in the history
Add Google Analytics to sub-pages
  • Loading branch information
chasenlehara authored May 31, 2017
2 parents ba530a0 + f6ba57c commit ea207ec
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 13 deletions.
1 change: 1 addition & 0 deletions make-example.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ generate(docMap, {
},
dest: path.join(__dirname, "temp"),
parent: "StealJS",
googleAnalyticsTrackingCode: 'UA-2302003-20',
forceBuild: forceBuild,
minifyBuild: false,
debug: true
Expand Down
5 changes: 5 additions & 0 deletions templates/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ module.exports = function(docMap, config, getCurrent, oldHelpers, OtherHandlebar

return parents;
},

googleAnalyticsTrackingCode: function() {
return config.googleAnalyticsTrackingCode;
},

/**
* @function documentjs.generators.html.defaultHelpers.makeTitle
* Given the docObject context, returns a "pretty" name that is used
Expand Down
37 changes: 24 additions & 13 deletions templates/layout.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@
{{#unless devBuild}}
<link rel="stylesheet" type="text/css" href="{{pathToDest}}/static/bundles/bit-docs-site/static.css">
{{/unless}}
{{#with (googleAnalyticsTrackingCode)}}
<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','https://www.google-analytics.com/analytics.js','ga');
ga('create', '{{.}}', 'auto');
ga('send', 'pageview');
</script>
{{/with}}
<!--[if lt IE 9]>
<script type="text/javascript" src="static/html5shiv.js"></script>
<![endif]-->
Expand All @@ -40,15 +51,15 @@
<ul class="dropdown-menu">
<li><a href="https://donejs.com/">DoneJS</a></li>
<li><a href="http://stealjs.com/">StealJS</a></li>
<li><a href="http://jquerypp.com/">jQuery ++</a></li>
<li><a href="https://stealjs.com/">StealJS</a></li>
<li><a href="https://jquerypp.com/">jQuery ++</a></li>
<li><a href="https://funcunit.com/">FuncUnit</a></li>
<li><a href="http://documentjs.com/">DocumentJS</a></li>
<li><a href="https://documentjs.com/">DocumentJS</a></li>
</ul>
</div>
<ul class="nav">
<li><a href="http://stealjs.com">Home</a></li>
<li><a href="https://stealjs.com">Home</a></li>
{{#ifEqual page "index"}}
<li><a href="{{urlTo 'index'}}">Api</a></li>
Expand All @@ -63,16 +74,16 @@
<div class="pull-right">
<div class="bitovi-menu">
<a href="http://bitovi.com" class="bitovi icon-bits">Bitovi</a>
<a href="https://www.bitovi.com" class="bitovi icon-bits">Bitovi</a>
<ul class="dropdown-menu">
<li><a href="http://bitovi.com">Bitovi.com</a></li>
<li><a href="http://bitovi.com/blog/">Blog</a></li>
<li><a href="http://bitovi.com/design/">Design</a></li>
<li><a href="http://bitovi.com/development/">Development</a></li>
<li><a href="http://bitovi.com/training/">Training</a></li>
<li><a href="http://bitovi.com/open-source/">Open Source</a></li>
<li><a href="http://bitovi.com/people/">People</a></li>
<li><a href="http://bitovi.com/contact/">Contact Us</a></li>
<li><a href="https://www.bitovi.com">Bitovi.com</a></li>
<li><a href="https://www.bitovi.com/blog">Blog</a></li>
<li><a href="https://www.bitovi.com/design">Design</a></li>
<li><a href="https://www.bitovi.com/development">Development</a></li>
<li><a href="https://www.bitovi.com/training">Training</a></li>
<li><a href="https://www.bitovi.com/open-source">Open Source</a></li>
<li><a href="https://www.bitovi.com/about">About</a></li>
<li><a href="https://www.bitovi.com/contact">Contact Us</a></li>
</ul>
</div>
</div>
Expand Down

0 comments on commit ea207ec

Please sign in to comment.