Skip to content

Commit

Permalink
add google analytics tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
esvit committed Oct 9, 2013
1 parent d3666cf commit 4735606
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 8 deletions.
2 changes: 1 addition & 1 deletion angular-social.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion angular-social.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 28 additions & 3 deletions angular-social.src.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ app.directive('ngSocialButtons', ['$compile', '$q', '$parse', '$http', '$locatio
}
e.preventDefault();

if (options.track && angular.isArray(_gaq)) {
_gaq.push(['_trackSocial', options.track.name, options.track.action, $scope.url]);
}

var process = true;
if (angular.isFunction(options.click)) {
process = options.click.call(this, options);
Expand Down Expand Up @@ -122,6 +126,10 @@ app.directive('ngSocialFacebook', function() {
url: 'http://www.facebook.com/sharer/sharer.php?u={url}',
width: 600,
height: 500
},
track: {
'name': 'facebook',
'action': 'send'
}
};
return {
Expand Down Expand Up @@ -168,6 +176,10 @@ app.directive('ngSocialTwitter', function() {
// Add colon to improve readability
if (!/[\.:\-]\s*$/.test(options.pageTitle)) options.pageTitle += ':';
return true;
},
track: {
'name': 'twitter',
'action': 'tweet'
}
};
return {
Expand Down Expand Up @@ -210,6 +222,10 @@ app.directive('ngSocialGooglePlus', ['$parse', function($parse) {
url: 'https://plus.google.com/share?url={url}',
width: 700,
height: 500
},
track: {
'name': 'Google+',
'action': 'share'
}
};
return {
Expand Down Expand Up @@ -265,6 +281,10 @@ app.directive('ngSocialVk', function() {
url: 'http://vk.com/share.php?url={url}&title={title}&description={description}&image={image}',
width: 550,
height: 330
},
track: {
'name': 'VKontakte',
'action': 'share'
}
};
return {
Expand Down Expand Up @@ -307,6 +327,10 @@ angular.module("ngSocial").directive('ngSocialOdnoklassniki', function() {
url: 'http://www.odnoklassniki.ru/dk?st.cmd=addShare&st._surl={url}',
width: 550,
height: 360
},
track: {
'name': 'Odnoklassniki',
'action': 'share'
}
};
return {
Expand Down Expand Up @@ -505,8 +529,6 @@ angular.module("ngSocial").directive('ngSocialGithub', function() {
}
}
});
'use strict';

app.directive('ngSocialStumbleupon', ['$parse', function ($parse) {
'use strict';

Expand All @@ -521,6 +543,10 @@ app.directive('ngSocialStumbleupon', ['$parse', function ($parse) {
url: 'http://www.stumbleupon.com/submit?url={url}&title={title}',
width: 800,
height: 600
},
track: {
'name': 'StumbleUpon',
'action': 'share'
}
};
return {
Expand Down Expand Up @@ -549,7 +575,6 @@ app.directive('ngSocialStumbleupon', ['$parse', function ($parse) {
}
};
}]);

angular.module('ngSocial').run(['$templateCache', function ($templateCache) {
$templateCache.put('/views/buttons.html', '<div class="ng-social-container ng-cloak"><ul class="ng-social" ng-transclude></ul></div>');
}]);
4 changes: 4 additions & 0 deletions src/scripts/00-directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ app.directive('ngSocialButtons', ['$compile', '$q', '$parse', '$http', '$locatio
}
e.preventDefault();

if (options.track && angular.isArray(_gaq)) {
_gaq.push(['_trackSocial', options.track.name, options.track.action, $scope.url]);
}

var process = true;
if (angular.isFunction(options.click)) {
process = options.click.call(this, options);
Expand Down
4 changes: 4 additions & 0 deletions src/scripts/02-facebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ app.directive('ngSocialFacebook', function() {
url: 'http://www.facebook.com/sharer/sharer.php?u={url}',
width: 600,
height: 500
},
track: {
'name': 'facebook',
'action': 'send'
}
};
return {
Expand Down
4 changes: 4 additions & 0 deletions src/scripts/03-twitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ app.directive('ngSocialTwitter', function() {
// Add colon to improve readability
if (!/[\.:\-]\s*$/.test(options.pageTitle)) options.pageTitle += ':';
return true;
},
track: {
'name': 'twitter',
'action': 'tweet'
}
};
return {
Expand Down
4 changes: 4 additions & 0 deletions src/scripts/04-google-plus.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ app.directive('ngSocialGooglePlus', ['$parse', function($parse) {
url: 'https://plus.google.com/share?url={url}',
width: 700,
height: 500
},
track: {
'name': 'Google+',
'action': 'share'
}
};
return {
Expand Down
4 changes: 4 additions & 0 deletions src/scripts/05-vk.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ app.directive('ngSocialVk', function() {
url: 'http://vk.com/share.php?url={url}&title={title}&description={description}&image={image}',
width: 550,
height: 330
},
track: {
'name': 'VKontakte',
'action': 'share'
}
};
return {
Expand Down
4 changes: 4 additions & 0 deletions src/scripts/06-odnoklassniki.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ angular.module("ngSocial").directive('ngSocialOdnoklassniki', function() {
url: 'http://www.odnoklassniki.ru/dk?st.cmd=addShare&st._surl={url}',
width: 550,
height: 360
},
track: {
'name': 'Odnoklassniki',
'action': 'share'
}
};
return {
Expand Down
Loading

0 comments on commit 4735606

Please sign in to comment.