Skip to content

Commit

Permalink
Merge pull request #235 from MAPC/igmh/google-analytics
Browse files Browse the repository at this point in the history
Add google analytics to ember
  • Loading branch information
iangmhill authored Jul 20, 2018
2 parents 9891ce4 + 49a1353 commit 03e09c9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
12 changes: 12 additions & 0 deletions ember/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">

<!-- 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','https://www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-5547782-31', 'auto');
ga('send', 'pageview');
</script>
<!-- End Google Analytics -->

{{content-for "head"}}

<link integrity="" rel="stylesheet" href="{{rootURL}}assets/vendor.css">
Expand Down
10 changes: 9 additions & 1 deletion ember/app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@ import config from './config/environment';

const Router = EmberRouter.extend({
location: config.locationType,
rootURL: config.rootURL
rootURL: config.rootURL,
didTransition: function() {
this._super(...arguments);

return ga('send', 'pageview', {
'page': this.get('url'),
'title': this.get('url')
});
}
});

Router.map(function() {
Expand Down

0 comments on commit 03e09c9

Please sign in to comment.