Skip to content

Commit 8e778e2

Browse files
committed
Add Google Analytics to sub-pages
Related to stealjs/stealjs#48
1 parent ba530a0 commit 8e778e2

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

make-example.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ generate(docMap, {
2323
},
2424
dest: path.join(__dirname, "temp"),
2525
parent: "StealJS",
26+
googleAnalyticsTrackingCode: 'UA-2302003-20',
2627
forceBuild: forceBuild,
2728
minifyBuild: false,
2829
debug: true

templates/helpers.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,11 @@ module.exports = function(docMap, config, getCurrent, oldHelpers, OtherHandlebar
201201

202202
return parents;
203203
},
204+
205+
googleAnalyticsTrackingCode: function() {
206+
return config.googleAnalyticsTrackingCode;
207+
},
208+
204209
/**
205210
* @function documentjs.generators.html.defaultHelpers.makeTitle
206211
* Given the docObject context, returns a "pretty" name that is used

templates/layout.mustache

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@
2424
{{#unless devBuild}}
2525
<link rel="stylesheet" type="text/css" href="{{pathToDest}}/static/bundles/bit-docs-site/static.css">
2626
{{/unless}}
27+
{{#with (googleAnalyticsTrackingCode)}}
28+
<script>
29+
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
30+
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
31+
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
32+
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
33+
34+
ga('create', '{{.}}', 'auto');
35+
ga('send', 'pageview');
36+
</script>
37+
{{/with}}
2738
<!--[if lt IE 9]>
2839
<script type="text/javascript" src="static/html5shiv.js"></script>
2940
<![endif]-->

0 commit comments

Comments
 (0)