'use strict';

var angular = require('angular')
  , app = angular.module('mjbondra.components.google-analytics.directives', []);

app.directive('googleAnalytics', [
  '$location',
  'ga',
  function ($location, ga) {
    return {
      link: function (scope) {
        ga('create', scope.googleAnalytics, 'auto');
      },
      scope: {
        googleAnalytics: '@'
      }
    };
  }
]);

app.directive('sendPageview', [
  '$location',
  'ga',
  function ($location, ga) {
    return {
      link: function (scope, element, attributes) {
        element.ready(function () {
          ga('send', 'pageview', {
            page: $location.path(),
            title: attributes.sendPageview || element.text()
          });
        });
      }
    };
  }
]);

@@ -250,16 +250,37 @@
 n (scope
+, element, attributes
 ) %7B%0A    
@@ -296,21 +296,26 @@
 reate', 
-scope
+attributes
 .googleA
@@ -337,61 +337,8 @@
 ');%0A
-      %7D,%0A      scope: %7B%0A        googleAnalytics: '@'%0A
     

update google-analytics directive