Ember Octane is here! A lot has changed since Ember 3.14, including these Guides. Read more in the Ember Blog.

Old Guides - You are viewing the guides for Ember v1.10.0. VIEW v3.15.0
Edit Page

Adding Google Analytics Tracking


You want to add analytics to your Ember application.


Subscribe to the didTransition event inside your application router.

In the following examples we're using Google Analytics but it could be any other analytics product. Add Google analytic's base code to the html file that renders your ember app.

<html lang="en">
  <title>My Ember Site</title>
  <script type="text/javascript">

    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-XXXXX-Y']);

    (function() {
      var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
      ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
      var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);



Then reopen the application router and add this function. It will be called when didTransition is fired by the router.

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


The didTransition event is responsible for notifying listeners of any URL changes, in this example we are getting the path after the hash in the url so we can notify Google Analytics about moving between areas of the site.

JSBin Example