Skip to content
This repository has been archived by the owner on Dec 5, 2022. It is now read-only.

Commit

Permalink
feat(ga): add google analytics support
Browse files Browse the repository at this point in the history
  • Loading branch information
rbarilani committed Jul 10, 2017
1 parent 04ee2ac commit e2e6cc4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,20 @@ Right now there are two `types` of navigation items:

#### Favicon

Fill in `favicon` property with the path pointing to your favicon (always relative to `source` folder)

```
theme_config:
favicon: path/to/favicon.ico
```
#### Google Analytics
Fill in `google_analytics` property with your tracking ID.
```
theme_config:
favicon: /path/to/favicon.ico
google_analytics: your-tracking-id
```
#### Search
Expand Down
10 changes: 10 additions & 0 deletions layout/google_analytics.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<% if (config.theme_config.google_analytics){ %>
<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', '<%= config.theme_config.google_analytics %>', 'auto');
ga('send', 'pageview');
</script>
<% } %>
5 changes: 4 additions & 1 deletion layout/layout.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
</head>
<body>
<%- body %>

<%- partial('google_analytics.ejs') %>

<script
src="https://code.jquery.com/jquery-3.2.1.min.js"
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
Expand All @@ -25,7 +28,7 @@
<script src="<%- url_for('script/smooth-scroll.min.js') %>"></script>
<script src="<%- url_for('script/main.js') %>"></script>

<script type="text/javascript" src="//cdn.jsdelivr.net/docsearch.js/2.1.8/docsearch.min.js"></script>
<script type="text/javascript" src="//cdn.jsdelivr.net/fastclick/1.0.6/fastclick.min.js"></script>

</body>
</html>

0 comments on commit e2e6cc4

Please # to comment.