Permalink
Browse files

Add support for Google Analytics

  • Loading branch information...
PierreLvx committed Dec 30, 2016
1 parent 0c3dde7 commit f17789abb26a6071b2a0e64005bba6fc5da2d4dd
Showing with 38 additions and 1 deletion.
  1. +12 −0 README.md
  2. +3 −0 _config.yml
  3. +15 −0 _includes/analytics.html
  4. +4 −1 _includes/head.html
  5. +4 −0 _layouts/default.html
View
@@ -216,6 +216,18 @@ The attribute 'style' may not appear in tag 'span'
The attribute 'style' may not appear in tag 'div'
```
## Enabling Google Analytics
This theme supports simple [page tracking](https://developers.google.com/analytics/devguides/collection/amp-analytics/#page_tracking) with Google Analytics.
To enable analytics :
1. Set your property ID in `_config.yml`
2. Uncomment the analytics include in `_layouts/default.html`.
3. Uncomment the analytics script in `_includes/head.html`.
If you wish to track custom events or want to send custom data, please refer to [the documentation](https://developers.google.com/analytics/devguides/collection/amp-analytics/#event_tracking).
## Making Google serve your page
Google will cache valid AMP pages if you link to them with one of these urls:
View
@@ -23,6 +23,9 @@ author_image: "/assets/images/author.jpg"
twitter_username: jekyllrb
github_username: jekyll
# Google Analytics
analytics_id: ""
# Build settings
markdown: kramdown
View
@@ -0,0 +1,15 @@
<amp-analytics type="googleanalytics" id="amp-analytics">
<script type="application/json">
{
"vars": {
"account": "{{ site.analytics_id }}"
},
"triggers": {
"trackPageview": {
"on": "visible",
"request": "pageview"
}
}
}
</script>
</amp-analytics>
View
@@ -2,6 +2,9 @@
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,300,700' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Lora:400,700' rel='stylesheet' type='text/css'>
<script async custom-element="amp-youtube" src="https://cdn.ampproject.org/v0/amp-youtube-0.1.js"></script>
{% comment %}
<script async custom-element="amp-analytics" src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js"></script>
{% endcomment %}
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
@@ -16,7 +19,7 @@
<script type="application/ld+json">
{% include metadata.json %}
</script>
<style amp-custom>
{% capture include_to_scssify %}
{% include styles.scss %}
View
@@ -5,5 +5,9 @@
{% include header.html %}
{{ content }}
{% comment %}
{% include analytics.html %}
{% endcomment %}
</body>
</html>

0 comments on commit f17789a

Please sign in to comment.