Browse code
Added Piwik analytics
E L authored on 13/10/2015 10:06:50
Showing 5 changed files
Showing 5 changed files
- .gitignore
- static/index.html
- static/js/new/controller.js
- static/lib/angulartics-piwik.js
- static/login.html
... | ... |
@@ -33,6 +33,7 @@ |
33 | 33 |
<script src="/lib/angular-resource.min.js"></script> |
34 | 34 |
<script src="/lib/angulartics.min.js"></script> |
35 | 35 |
<script src="/lib/angulartics-ga.min.js"></script> |
36 |
+ <script src="/lib/angulartics-piwik.js"></script> |
|
36 | 37 |
<script src="/js/new/utils.js"></script> |
37 | 38 |
<script src="/js/new/directives.js"></script> |
38 | 39 |
<script src="/js/directives/user-badge/user-badge.js"></script> |
... | ... |
@@ -108,5 +109,24 @@ |
108 | 109 |
//ga('send', 'pageview'); |
109 | 110 |
|
110 | 111 |
</script> |
112 |
+<!-- Piwik --> |
|
113 |
+<script type="text/javascript"> |
|
114 |
+ var _paq = _paq || []; |
|
115 |
+ _paq.push(["setDocumentTitle", document.domain + "/" + document.title]); |
|
116 |
+ _paq.push(["setCookieDomain", "*.joinmarrow.com"]); |
|
117 |
+ _paq.push(["setDomains", ["*.joinmarrow.com"]]); |
|
118 |
+ _paq.push(['trackPageView']); |
|
119 |
+ _paq.push(['enableLinkTracking']); |
|
120 |
+ (function() { |
|
121 |
+ var u="//piwik.elangley.org/"; |
|
122 |
+ _paq.push(['setTrackerUrl', u+'piwik.php']); |
|
123 |
+ _paq.push(['setSiteId', 2]); |
|
124 |
+ var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; |
|
125 |
+ g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s); |
|
126 |
+ })(); |
|
127 |
+</script> |
|
128 |
+<noscript><p><img src="//piwik.elangley.org/piwik.php?idsite=2" style="border:0;" alt="" /></p></noscript> |
|
129 |
+<!-- End Piwik Code --> |
|
130 |
+ |
|
111 | 131 |
</body> |
112 | 132 |
</html> |
... | ... |
@@ -1,6 +1,6 @@ |
1 | 1 |
var marrowApp = angular.module('marrowApp', ['ngRoute', 'marrowApp.services', 'marrowApp.directives', 'marrowApp.utils', |
2 | 2 |
'marrowApp.directives.boneList', 'marrowApp.directives.userBadge', |
3 |
- 'angulartics', 'angulartics.google.analytics']); |
|
3 |
+ 'angulartics', 'angulartics.google.analytics', 'angulartics.piwik']); |
|
4 | 4 |
|
5 | 5 |
marrowApp.config(['$routeProvider', |
6 | 6 |
function($routeProvider) { |
7 | 7 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,103 @@ |
1 |
+/** |
|
2 |
+ * @license Angulartics v0.19.2 |
|
3 |
+ * (c) 2013 Luis Farzati http://luisfarzati.github.io/angulartics |
|
4 |
+ * Piwik 2.1.x update contributed by http://github.com/highskillz |
|
5 |
+ * License: MIT |
|
6 |
+ */ |
|
7 |
+ |
|
8 |
+/* global _paq */ |
|
9 |
+ |
|
10 |
+(function(angular) { |
|
11 |
+ 'use strict'; |
|
12 |
+ |
|
13 |
+ /** |
|
14 |
+ * @ngdoc overview |
|
15 |
+ * @name angulartics.piwik |
|
16 |
+ * Enables analytics support for Piwik (http://piwik.org/docs/tracking-api/) |
|
17 |
+ */ |
|
18 |
+ angular.module('angulartics.piwik', ['angulartics']) |
|
19 |
+ .config(['$analyticsProvider', '$windowProvider', |
|
20 |
+ function($analyticsProvider, $windowProvider) { |
|
21 |
+ var $window = $windowProvider.$get(); |
|
22 |
+ |
|
23 |
+ $analyticsProvider.settings.pageTracking.trackRelativePath = true; |
|
24 |
+ |
|
25 |
+ // Add piwik specific trackers to angulartics API |
|
26 |
+ |
|
27 |
+ // scope: visit or page. Defaults to 'page' |
|
28 |
+ $analyticsProvider.api.setCustomVariable = function(varIndex, varName, value, scope) { |
|
29 |
+ if ($window._paq) { |
|
30 |
+ scope = scope || 'page'; |
|
31 |
+ $window._paq.push(['setCustomVariable', varIndex, varName, value, scope]); |
|
32 |
+ } |
|
33 |
+ }; |
|
34 |
+ |
|
35 |
+ // trackSiteSearch(keyword, category, [searchCount]) |
|
36 |
+ $analyticsProvider.api.trackSiteSearch = function(keyword, category, searchCount) { |
|
37 |
+ |
|
38 |
+ // keyword is required |
|
39 |
+ if ($window._paq && keyword) { |
|
40 |
+ |
|
41 |
+ var params = ['trackSiteSearch', keyword, category || false]; |
|
42 |
+ |
|
43 |
+ // searchCount is optional |
|
44 |
+ if (angular.isDefined(searchCount)) { |
|
45 |
+ params.push(searchCount); |
|
46 |
+ } |
|
47 |
+ |
|
48 |
+ $window._paq.push(params); |
|
49 |
+ } |
|
50 |
+ }; |
|
51 |
+ |
|
52 |
+ // logs a conversion for goal 1. revenue is optional |
|
53 |
+ // trackGoal(goalID, [revenue]); |
|
54 |
+ $analyticsProvider.api.trackGoal = function(goalID, revenue) { |
|
55 |
+ if ($window._paq) { |
|
56 |
+ _paq.push(['trackGoal', goalID, revenue || 0]); |
|
57 |
+ } |
|
58 |
+ }; |
|
59 |
+ |
|
60 |
+ // Set default angulartics page and event tracking |
|
61 |
+ |
|
62 |
+ // $analytics.setUsername(username) |
|
63 |
+ $analyticsProvider.registerSetUsername(function(username) { |
|
64 |
+ if ($window._paq) { |
|
65 |
+ $window._paq.push(['setUserId', username]); |
|
66 |
+ } |
|
67 |
+ }); |
|
68 |
+ |
|
69 |
+ // $analytics.setAlias(alias) |
|
70 |
+ // $analyticsProvider.registerSetAlias(function(param) { |
|
71 |
+ // // TODO: No piwik corresponding function found. Use setCustomVariable instead |
|
72 |
+ // }); |
|
73 |
+ |
|
74 |
+ // $analytics.setUserProperties(properties) |
|
75 |
+ // $analyticsProvider.registerSetUserProperties(function(param) { |
|
76 |
+ // // TODO: No piwik corresponding function found. Use setCustomVariable instead |
|
77 |
+ // }); |
|
78 |
+ |
|
79 |
+ // locationObj is the angular $location object |
|
80 |
+ $analyticsProvider.registerPageTrack(function(path, locationObj) { |
|
81 |
+ if ($window._paq) { |
|
82 |
+ $window._paq.push(['setDocumentTitle', $window.document.title]); |
|
83 |
+ $window._paq.push(['setCustomUrl', path]); |
|
84 |
+ $window._paq.push(['trackPageView']); |
|
85 |
+ } |
|
86 |
+ }); |
|
87 |
+ |
|
88 |
+ // trackEvent(category, event, [name], [value]) |
|
89 |
+ $analyticsProvider.registerEventTrack(function(action, properties) { |
|
90 |
+ if ($window._paq) { |
|
91 |
+ // PAQ requires that eventValue be an integer, see: http://piwik.org/docs/event-tracking/ |
|
92 |
+ if (properties.value) { |
|
93 |
+ var parsed = parseInt(properties.value, 10); |
|
94 |
+ properties.value = isNaN(parsed) ? 0 : parsed; |
|
95 |
+ } |
|
96 |
+ |
|
97 |
+ $window._paq.push(['trackEvent', properties.category, action, properties.label, properties.value]); |
|
98 |
+ } |
|
99 |
+ }); |
|
100 |
+ |
|
101 |
+ } |
|
102 |
+ ]); |
|
103 |
+})(angular); |
... | ... |
@@ -53,5 +53,23 @@ |
53 | 53 |
</form> |
54 | 54 |
</div> |
55 | 55 |
</main> |
56 |
+<!-- Piwik --> |
|
57 |
+<script type="text/javascript"> |
|
58 |
+ var _paq = _paq || []; |
|
59 |
+ _paq.push(["setDocumentTitle", document.domain + "/" + document.title]); |
|
60 |
+ _paq.push(["setCookieDomain", "*.joinmarrow.com"]); |
|
61 |
+ _paq.push(["setDomains", ["*.joinmarrow.com"]]); |
|
62 |
+ _paq.push(['trackPageView']); |
|
63 |
+ _paq.push(['enableLinkTracking']); |
|
64 |
+ (function() { |
|
65 |
+ var u="//piwik.elangley.org/"; |
|
66 |
+ _paq.push(['setTrackerUrl', u+'piwik.php']); |
|
67 |
+ _paq.push(['setSiteId', 2]); |
|
68 |
+ var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; |
|
69 |
+ g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s); |
|
70 |
+ })(); |
|
71 |
+</script> |
|
72 |
+<noscript><p><img src="//piwik.elangley.org/piwik.php?idsite=2" style="border:0;" alt="" /></p></noscript> |
|
73 |
+<!-- End Piwik Code --> |
|
56 | 74 |
</body> |
57 | 75 |
</html> |