govuk_admin_template 1.5.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f26fb03239eb4f100ba9371be1981747cf3766da
4
- data.tar.gz: 640a3fbb6b45fa1d9ef1bc0dc136b86493e76e8b
3
+ metadata.gz: 1be05142b9ea4a7b5df0e994e877937293135fdf
4
+ data.tar.gz: ad1fcdff74b55e486565929230502b92898e7f89
5
5
  SHA512:
6
- metadata.gz: 73c41a5c172b1e8c27b7a472435af7e63be624c3b931d22ec713f7529940aa648eabe30c13affa94fc828c4af762de7b9fe82af095b5a99af153acb15d9a44f3
7
- data.tar.gz: 89983d83d8038eb489a4d05926eb074f0507eb9fdb2a475a251a3d36b0568f49b093e715ca367d972767d236ea89092e2440d2e74e0e1f5980c40490f38d4ef1
6
+ metadata.gz: 1edc24beaaa1ef1fdf833072659ecff6333f57a7d8f85e45457005041a0459d468505058756601be8d71219387a2957285aab34e339b6b67a8420d9222a722c0
7
+ data.tar.gz: 94d8caafc79f568d1eaea021f559ea87165144af352d6d4654f39e23bd998352d1aee561b37f1dbf36f9a73bb76c9eba58e443e305ae7d7c35d3821dd994997c
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # 2.0.0
2
+
3
+ * Manage Google Analytics tracking
4
+ * Update event and pageview tracking API, deprecate classic GA event tracking
5
+
1
6
  # 1.5.1
2
7
 
3
8
  * Rename SASS files to exclude `.css` and fix deprecation warnings
data/README.md CHANGED
@@ -10,6 +10,7 @@ This gem provides (via a Rails engine):
10
10
  * Admin design patterns available from `/style-guide` (when routes are mounted)
11
11
  * [CSS helpers and SASS variables](CSS.md) for the admin theme
12
12
  * GOV.UK user friendly date formats
13
+ * Google Analytics tracking code (Universal Analytics), using the "GOV.UK apps" profile
13
14
 
14
15
  [Apps using this gem](https://github.com/search?q=govuk_admin_template+user%3Aalphagov+filename%3AGemfile) include:
15
16
  * [Transition](https://github.com/alphagov/transition)
@@ -70,26 +70,34 @@
70
70
  window.location.href = path;
71
71
  }
72
72
 
73
+ // Google Analytics pageview tracking
74
+ GOVUKAdmin.trackPageview = function(path, title) {
75
+ var pageviewObject = { page: path };
76
+
77
+ if (typeof title === "string") {
78
+ pageviewObject.title = title;
79
+ }
80
+
81
+ if (typeof root.ga === "function") {
82
+ // https://developers.google.com/analytics/devguides/collection/analyticsjs/pages
83
+ root.ga('send', 'pageview', pageviewObject);
84
+ }
85
+ }
86
+
73
87
  // Google Analytics event tracking
74
88
  // Label and value are optional
75
- GOVUKAdmin.track = function(action, label, value) {
89
+ GOVUKAdmin.trackEvent = function(action, label, value) {
76
90
 
91
+ // https://developers.google.com/analytics/devguides/collection/analyticsjs/events
77
92
  // Default category to the page an event occurs on
78
- var category = root.location.pathname,
79
-
80
- // https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide
81
- eventGa = ["_trackEvent", category, action],
82
-
83
- // https://developers.google.com/analytics/devguides/collection/analyticsjs/events
84
- eventAnalytics = {
93
+ var eventAnalytics = {
85
94
  hitType: 'event',
86
- eventCategory: category,
95
+ eventCategory: root.location.pathname,
87
96
  eventAction: action
88
97
  };
89
98
 
90
99
  // Label is optional
91
100
  if (typeof label === "string") {
92
- eventGa.push(label);
93
101
  eventAnalytics.eventLabel = label;
94
102
  }
95
103
 
@@ -99,18 +107,13 @@
99
107
  if (value) {
100
108
  value = parseInt(value, 10);
101
109
  if (typeof value === "number" && !isNaN(value)) {
102
- eventGa.push(value);
103
110
  eventAnalytics.eventValue = value;
104
111
  }
105
112
  }
106
113
 
107
- // _gaq is the Google Analytics tracking object we
108
- // push events to when using the old tracking code
109
- root._gaq = root._gaq || [];
110
-
111
114
  // Useful for debugging:
112
- // console.log(eventGa, eventAnalytics);
113
- root._gaq.push(eventGa);
115
+ // console.log(eventAnalytics);
116
+
114
117
  if (typeof root.ga === "function") {
115
118
  root.ga('send', eventAnalytics);
116
119
  }
@@ -8,7 +8,7 @@
8
8
  label = element.data('track-label'),
9
9
  value = element.data('track-value');
10
10
 
11
- GOVUKAdmin.track(action, label, value);
11
+ GOVUKAdmin.trackEvent(action, label, value);
12
12
  }
13
13
  };
14
14
 
@@ -91,5 +91,16 @@
91
91
  </footer>
92
92
  </section>
93
93
  <%= yield :body_end %>
94
+ <% if Rails.env.production? %>
95
+ <script class="analytics">
96
+ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
97
+ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
98
+ m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
99
+ })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
100
+
101
+ ga('create', 'UA-26179049-6', 'alphagov.co.uk');
102
+ ga('send', 'pageview');
103
+ </script>
104
+ <% end %>
94
105
  </body>
95
106
  </html>
@@ -1,3 +1,3 @@
1
1
  module GovukAdminTemplate
2
- VERSION = "1.5.1"
2
+ VERSION = "2.0.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_admin_template
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-06 00:00:00.000000000 Z
11
+ date: 2015-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails