Skip to content

Commit

Permalink
feat(template): add Google Analytics support
Browse files Browse the repository at this point in the history
  • Loading branch information
sparanoid committed Aug 21, 2015
1 parent 5d2c152 commit adde9c7
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 0 deletions.
15 changes: 15 additions & 0 deletions _app/_includes/_amsf.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,18 @@
{% capture amsf_page_thumb %}
{{ site.file }}/thumb/{% if page.thumb %}{{ page.thumb }}{% else %}na.png{% endif %}
{% endcapture %}

<!-- Google Analytics tracking code -->
{% capture amsf_google_analytics %}
{% if site.google_analytics.enabled %}
<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','{{ site.google_analytics.url }}','ga');

ga('create', '{{ site.google_analytics.id }}', 'auto');
ga('send', 'pageview');
</script>
{% endif %}
{% endcapture %}
3 changes: 3 additions & 0 deletions _app/_includes/themes/curtana/includes/js.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
<!-- User custom scripts -->
<script src="{{ '/js/custom.js?assets-inline' | prepend: amsf_user_assets }}"></script>

<!-- Google Analytics tracking code -->
{{ amsf_google_analytics }}

<!-- Foot hooks -->
{% if page.foot %}
{{ page.foot }}
Expand Down
9 changes: 9 additions & 0 deletions _app/_posts/note/2014-06-09-creating-themes.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,15 @@ This allow your user to define page / post specific CSS blocks in front-matter d
{% raw %}{{ amsf_page_css }}{% endraw %}
```

### Google Analytics Support

This allow your user to be able to use Google Analytics for their site, tracking ID can be changed in config file:

```html
<!-- Google Analytics tracking code -->
{{ amsf_google_analytics }}
```

## Publishing Themes

You really like your custom design and wanna show it off to the world? Cool, you can create (pack) you own theme by the following command:
Expand Down
6 changes: 6 additions & 0 deletions _config.init.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ file: //d349cztnlupsuf.cloudfront.net
# Download files URL used in posts, ie. href="{{ site.download }}/package.zip", this should also be a CDN link just like `site.url`. There's no differences in `site.url` and `site.download`, I just use one CDN for post images and another for large download files. That's it. Remove or ignore this if you don't need it
download: http://dl.sparanoid.com

# Google Analytics tracking code
google_analytics:
enabled: true
id: UA-xxxxxxx
url: //www.google-analytics.com/analytics.js

# Site Twitter account handle
twitter: sparanoid

Expand Down
6 changes: 6 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ file: //d349cztnlupsuf.cloudfront.net
# Download files URL used in posts, ie. href="{{ site.download }}/package.zip", this should also be a CDN link just like `site.url`. There's no differences in `site.url` and `site.download`, I just use one CDN for post images and another for large download files. That's it. Remove or ignore this if you don't need it
download: http://dl.sparanoid.com

# Google Analytics tracking code
google_analytics:
enabled: true
id: UA-xxxxxxx
url: //www.google-analytics.com/analytics.js

# Site Twitter account handle
twitter: sparanoid

Expand Down

0 comments on commit adde9c7

Please sign in to comment.